You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/02/20 10:03:34 UTC
[GitHub] [apisix] MirtoBusico opened a new issue #6387: request help: How to correct "proxy-rewrite err: invalid regex_uri(^/user/(*), /$1)"
MirtoBusico opened a new issue #6387:
URL: https://github.com/apache/apisix/issues/6387
### Issue description
Hi all,
In the apisix pod log I see this error and my route doesn't work.
The log:
```
2022-02-19T18:23:46.880Z | 2022/02/19 18:23:46 [error] 52#52: *3330301 [lua] config_etcd.lua:569: failed to fetch data from etcd: failed to check item data of [/apisix/routes] err:failed to check the configuration of plugin proxy-rewrite err: invalid regex_uri(^/user/(*), /$1): pcre_compile() failed: nothing to repeat in "^/user/(*)" at "*)", etcd key: /apisix/routes, context: ngx.timer
2022-02-19T18:23:46.880Z | 2022/02/19 18:23:46 [error] 46#46: *3326831 [lua] config_etcd.lua:569: failed to fetch data from etcd: failed to check item data of [/apisix/routes] err:failed to check the configuration of plugin proxy-rewrite err: invalid regex_uri(^/user/(*), /$1): pcre_compile() failed: nothing to repeat in "^/user/(*)" at "*)", etcd key: /apisix/routes, context: ngx.timer
2022-02-19T18:23:46.880Z | 2022/02/19 18:23:46 [error] 45#45: *3323345 [lua] config_etcd.lua:569: failed to fetch data from etcd: failed to check item data of [/apisix/routes] err:failed to check the configuration of plugin proxy-rewrite err: invalid regex_uri(^/user/(*), /$1): pcre_compile() failed: nothing to repeat in "^/user/(*)" at "*)", etcd key: /apisix/routes, context: ngx.timer
```
The route definition is:
```
{
"uri": "/user/*",
"name": "m01-www-user",
"desc": "services for users - access with authentication and role=user",
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
"CONNECT",
"TRACE"
],
"host": "www.m01.net",
"plugins": {
"proxy-rewrite": {
"regex_uri": [
"^/user/(*)",
"/$1"
]
},
"redirect": {
"http_to_https": true
}
},
"upstream_id": "394941006623015714",
"status": 1
}
```
Strangely this other route works perfectly
```
{
"uri": "/pres/*",
"name": "m01-www-free",
"desc": "application presentation - access without authentication",
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
"CONNECT",
"TRACE"
],
"host": "www.m01.net",
"plugins": {
"proxy-rewrite": {
"regex_uri": [
"^/pres/(*)",
"/$1"
]
},
"redirect": {
"http_to_https": true
}
},
"upstream_id": "394941006623015714",
"status": 1
}
```
Mybe it is a stupid type error; but I cannot figure out why this is correct
```
"^/pres/(*)",
```
and this is wrong
```
"^/user/(*)",
```
Any hint?
**After stop and start**
After shutting down and startup the entire kubernetes cluster the two routes are not working
There is no error signaled in the apisix log
In the browser you receive a route not found error
```
{"error_msg":"404 Route Not Found"}
```
### Environment
- apisix version (cmd: `apisix version`):
```
bash-5.1# apisix version
/usr/local/openresty/luajit/bin/luajit ./apisix/cli/apisix.lua version
2.12.0
bash-5.1#
```
- OS (cmd: `uname -a`):
```
bash-5.1# uname -a
Linux apisix-dd76474d9-82frr 5.4.0-99-generic #112-Ubuntu SMP Thu Feb 3 13:50:55 UTC 2022 x86_64 Linux
bash-5.1#
```
- OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):
```
bash-5.1# nginx -V
nginx version: openresty/1.19.9.1
built by gcc 10.3.1 20210424 (Alpine 10.3.1_git20210424)
built with OpenSSL 1.1.1g 21 Apr 2020
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DAPISIX_BASE_VER=1.19.9.1.3 -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl111/include' --add-module=../ngx_devel_kit-0.3.1 --add-module=../echo-nginx-module-0.62 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.32 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.08 --add-module=../srcache-nginx-module-0.32 --add-module=../ngx_lua-0.10.20 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.7 --add-module=../ngx_stream_lua-0.0.10 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -Wl,-rpath,/usr/local/openresty/wasmtime-c-ap
i/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl111/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl111/lib' --add-module=/tmp/tmp.I9j9kfjRTW/openresty-1.19.9.1/../mod_dubbo --add-module=/tmp/tmp.I9j9kfjRTW/openresty-1.19.9.1/../ngx_multi_upstream_module --add-module=/tmp/tmp.I9j9kfjRTW/openresty-1.19.9.1/../apisix-nginx-module --add-module=/tmp/tmp.I9j9kfjRTW/openresty-1.19.9.1/../apisix-nginx-module/src/stream --add-module=/tmp/tmp.I9j9kfjRTW/openresty-1.19.9.1/../wasm-nginx-module --add-module=/tmp/tmp.I9j9kfjRTW/openresty-1.19.9.1/../lua-var-nginx-module --with-poll_module --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_modul
e --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-compat --with-stream --with-http_ssl_module
bash-5.1# openresty -V
nginx version: openresty/1.19.9.1
built by gcc 10.3.1 20210424 (Alpine 10.3.1_git20210424)
built with OpenSSL 1.1.1g 21 Apr 2020
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DAPISIX_BASE_VER=1.19.9.1.3 -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl111/include' --add-module=../ngx_devel_kit-0.3.1 --add-module=../echo-nginx-module-0.62 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.32 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.08 --add-module=../srcache-nginx-module-0.32 --add-module=../ngx_lua-0.10.20 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.7 --add-module=../ngx_stream_lua-0.0.10 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -Wl,-rpath,/usr/local/openresty/wasmtime-c-ap
i/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl111/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl111/lib' --add-module=/tmp/tmp.I9j9kfjRTW/openresty-1.19.9.1/../mod_dubbo --add-module=/tmp/tmp.I9j9kfjRTW/openresty-1.19.9.1/../ngx_multi_upstream_module --add-module=/tmp/tmp.I9j9kfjRTW/openresty-1.19.9.1/../apisix-nginx-module --add-module=/tmp/tmp.I9j9kfjRTW/openresty-1.19.9.1/../apisix-nginx-module/src/stream --add-module=/tmp/tmp.I9j9kfjRTW/openresty-1.19.9.1/../wasm-nginx-module --add-module=/tmp/tmp.I9j9kfjRTW/openresty-1.19.9.1/../lua-var-nginx-module --with-poll_module --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_modul
e --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-compat --with-stream --with-http_ssl_module
bash-5.1#
```
- etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
```
What pod is erver-info API?
From the kubernetes dashboard I see that the image is:
docker.io/bitnami/etcd:3.4.16-debian-10-r14
```
- apisix-dashboard version, if have:
```
dashboard_version 2.10.1
```
- the plugin runner version, if the issue is about a plugin runner (cmd: depended on the kind of runner):
```
Don't know how to get the proxy-rewrite plugin version
```
- luarocks version, if the issue is about installation (cmd: `luarocks --version`):
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #6387: request help: How to correct "proxy-rewrite err: invalid regex_uri(^/user/(*), /$1)"
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #6387:
URL: https://github.com/apache/apisix/issues/6387#issuecomment-1046449453
test
```json
{
"uri": "/user/*",
"name": "m01-www-user",
"desc": "services for users - access with authentication and role=user",
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
"CONNECT",
"TRACE"
],
"host": "www.m01.net",
"plugins": {
"proxy-rewrite": {
"regex_uri": [
"^/user/(*)",
"/$1"
]
},
"redirect": {
"http_to_https": true
}
},
"upstream": {
"nodes": {
"httpbin.org:80": 1
},
"type": "roundrobin"
}
}
```
and got
```
{
"error_msg": "failed to check the configuration of plugin proxy-rewrite err: invalid regex_uri(^/pres/(*), /$1): pcre_compile() failed: nothing to repeat in \"^/pres/(*)\" at \"*)\""
}
```
test
```json
{
"uri": "/pres/*",
"name": "m01-www-user",
"desc": "services for users - access with authentication and role=user",
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
"CONNECT",
"TRACE"
],
"host": "www.m01.net",
"plugins": {
"proxy-rewrite": {
"regex_uri": [
"^/pres/(*)",
"/$1"
]
},
"redirect": {
"http_to_https": true
}
},
"upstream": {
"nodes": {
"httpbin.org:80": 1
},
"type": "roundrobin"
}
}
```
and got
```
{
"error_msg": "failed to check the configuration of plugin proxy-rewrite err: invalid regex_uri(^/pres/(*), /$1): pcre_compile() failed: nothing to repeat in \"^/pres/(*)\" at \"*)\""
}
```
so both of these two cases were wrong.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] MirtoBusico commented on issue #6387: request help: How to correct "proxy-rewrite err: invalid regex_uri(^/user/(*), /$1)"
Posted by GitBox <gi...@apache.org>.
MirtoBusico commented on issue #6387:
URL: https://github.com/apache/apisix/issues/6387#issuecomment-1046310248
Strangely for me this gives a syntax error
```
^/pres/(*)
```
but this is acceped and seems to work
```
^/pres/(.*)
```
Now the route definition is
```
{
"uri": "/pres/*",
"name": "pres-test",
"desc": "free access to presentation services",
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
"CONNECT",
"TRACE"
],
"host": "www.m01.net",
"plugins": {
"proxy-rewrite": {
"regex_uri": [
"^/pres/(.*)",
"/$1"
]
},
"redirect": {
"http_to_https": true
}
},
"upstream_id": "394941006623015714",
"status": 1
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] MirtoBusico commented on issue #6387: request help: How to correct "proxy-rewrite err: invalid regex_uri(^/user/(*), /$1)"
Posted by GitBox <gi...@apache.org>.
MirtoBusico commented on issue #6387:
URL: https://github.com/apache/apisix/issues/6387#issuecomment-1046635565
Thanks @tzssangglass as reported in your link the correct syntax is
```
^/pres/(.*)
```
and the wrong syntax is
```
^/pres/(*)
```
**Ok. The first syntax is the solution.**
But I'm curious why the other syntax is wrong.
If I understand correctly, if these regex:
- (...) indicates something that will be passed as parameter (eg $1)
- \* indicates 0 or more characters
- . indicates 1 and only one character
So, in my mind, ^/pres/(.\*) should match https://www.m01.net/pres/headers but don't match https://www.m01.net/pres/
and ^/pres/(\*) should match both https://www.m01.net/pres/headers and https://www.m01.net/pres/
But in my tests ^/pres/(.\*) matches both urls and I don't know why.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] MirtoBusico closed issue #6387: request help: How to correct "proxy-rewrite err: invalid regex_uri(^/user/(*), /$1)"
Posted by GitBox <gi...@apache.org>.
MirtoBusico closed issue #6387:
URL: https://github.com/apache/apisix/issues/6387
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] MirtoBusico commented on issue #6387: request help: How to correct "proxy-rewrite err: invalid regex_uri(^/user/(*), /$1)"
Posted by GitBox <gi...@apache.org>.
MirtoBusico commented on issue #6387:
URL: https://github.com/apache/apisix/issues/6387#issuecomment-1047173345
Ok. Thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #6387: request help: How to correct "proxy-rewrite err: invalid regex_uri(^/user/(*), /$1)"
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #6387:
URL: https://github.com/apache/apisix/issues/6387#issuecomment-1046450456
maybe you can ref: https://github.com/apache/apisix/blob/master/docs/en/latest/FAQ.md#how-to-strip-route-prefix-for-path-matching
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #6387: request help: How to correct "proxy-rewrite err: invalid regex_uri(^/user/(*), /$1)"
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #6387:
URL: https://github.com/apache/apisix/issues/6387#issuecomment-1047028831
> So, in my mind, ^/pres/(.*) should match [m01.net/pres/headers](https://www.m01.net/pres/headers) but don't match [m01.net/pres](https://www.m01.net/pres/)
The regular expressions here are used to match from the request uri, excluding the host.
> ^/pres/(*) should match both [m01.net/pres/headers](https://www.m01.net/pres/headers) and [m01.net/pres](https://www.m01.net/pres/)
`^/pres/(*)` is impossible to configure successfully, and I am not quite sure of the details inside, as far as I can remember, it has to do with the greedy mode of regular matching.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org