You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "akrjohn (via GitHub)" <gi...@apache.org> on 2023/03/21 02:58:09 UTC

[GitHub] [apisix] akrjohn opened a new issue, #9122: bug: plugins.proxy-rewrite does not work with path size > 2

akrjohn opened a new issue, #9122:
URL: https://github.com/apache/apisix/issues/9122

   ### Current Behavior
   
   While using the proxy-rewrite plugin it has been noted that we get a route not found error
   "404 Route Not Found"
   
   APISIX Version --> 3.1.0
   Deployed on Kubernetes
   
   
   
   1.  http://www.example.com/servicea/anything --> Works 200
   2. http://www.example.com/servicea/anything/123 --> Works 200
   3. http://www.example.com/servicea/cookies --> Works 200
   4. http://www.example.com/servicea/cookies/set/john/121 --> Not working --> 404 route not found
   
   This works when you directly curl
   curl -X GET "http://httpbin.org/cookies/set/john/121" -H "accept: text/plain"
   
   
   
   ### Expected Behavior
   
   i expect a proper redirect and get the results as per the apth.
   
   ### Error Logs
   
    "GET /servicea/cookies/12 HTTP/1.1" 404 233 0.060 "-" "insomnia/2022.7.5" XXXXXXXXX "http://www.example.com/cookies/set/john/121"
   
   ### Steps to Reproduce
   
   Config as follows.
   
    "proxy-rewrite": {
         "regex_uri": [
           "^/servicea/(.*)",
           "/${1}"
         ]
       }
   
   upstream
   
   {
     "nodes": [
       {
         "host": "httpbin.org",
         "port": 80,
         "weight": 1
       }
     ],
     "timeout": {
       "connect": 6,
       "send": 6,
       "read": 6
     },
     "type": "roundrobin",
     "scheme": "http",
     "pass_host": "pass",
     "name": "upstream 1",
     "keepalive_pool": {
       "idle_timeout": 60,
       "requests": 1000,
       "size": 320
     }
   }
   
   
   
   ### Environment
   
   - APISIX version 3.1.0
   - Operating system (Linux apisix-56fcf4d77-p97mm 5.4.196-108.356.amzn2.x86_64 #1 SMP Thu May 26 12:49:47 UTC 2022 x86_64 GNU/Linux):
   - OpenResty / Nginx version (nginx version: openresty/1.21.4.1
   built by gcc 10.2.1 20210110 (Debian 10.2.1-6)
   built with OpenSSL 1.1.1s  1 Nov 2022
   TLS SNI support enabled
   configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DAPISIX_BASE_VER=1.21.4.1.5 -DNGX_GRPC_CLI_ENGINE_PATH=/usr/local/openresty/libgrpc_engine.so -DNGX_HTTP_GRPC_CLI_ENGINE_PATH=/usr/local/openresty/libgrpc_engine.so -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.33 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.09 --add-module=../srcache-nginx-module-0.32 --add-module=../ngx_lua-0.10.21 --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.9 --ad
 d-module=../ngx_stream_lua-0.0.11 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -Wl,-rpath,/usr/local/openresty/wasmtime-c-api/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.4LxUDwBgw8/openresty-1.21.4.1/../mod_dubbo-1.0.2 --add-module=/tmp/tmp.4LxUDwBgw8/openresty-1.21.4.1/../ngx_multi_upstream_module-1.1.1 --add-module=/tmp/tmp.4LxUDwBgw8/openresty-1.21.4.1/../apisix-nginx-module-1.12.0 --add-module=/tmp/tmp.4LxUDwBgw8/openresty-1.21.4.1/../apisix-nginx-module-1.12.0/src/stream --add-module=/tmp/tmp.4LxUDwBgw8/openresty-1.21.4.1/../apisix-nginx-module-1.12.0/src/meta --add-module=/tmp/tmp.4LxUDwBgw8/openresty-1.21.4.1/../wasm-nginx-module-0.6.4 --add-module=/tmp/tmp.4LxUDwBgw8/openresty-1.21.4.1/../lua-var-nginx-module-v0.5.3 --add-module=/tmp/tmp.4LxUDwBgw8/openresty-1.21.4.1/../grp
 c-client-nginx-module-v0.4.0 --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_module --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):
   
   - etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`):
   - APISIX Dashboard version, if relevant:
   - Plugin runner version, for issues related to plugin runners:
   - LuaRocks version, for installation issues (run `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.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] Gallardot commented on issue #9122: bug: plugins.proxy-rewrite does not work with path size > 2

Posted by "Gallardot (via GitHub)" <gi...@apache.org>.
Gallardot commented on issue #9122:
URL: https://github.com/apache/apisix/issues/9122#issuecomment-1489570160

   OK. I will close this issue. Feel free to reopen it if needed.


-- 
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] akrjohn commented on issue #9122: bug: plugins.proxy-rewrite does not work with path size > 2

Posted by "akrjohn (via GitHub)" <gi...@apache.org>.
akrjohn commented on issue #9122:
URL: https://github.com/apache/apisix/issues/9122#issuecomment-1478825414

   @soulbird here is the all the configuration
   
   routing
   
   {
     "uri": "/servicea/*",
     "name": "route1",
     "methods": [
       "GET",
       "POST",
       "PUT",
       "DELETE",
       "PATCH",
       "HEAD",
       "OPTIONS",
       "CONNECT",
       "TRACE",
       "PURGE"
     ],
     "plugins": {
       "proxy-rewrite": {
         "regex_uri": [
           "^/servicea/(.*)",
           "/${1}"
         ]
       }
     },
     "service_id": "452850410093281988",
     "status": 1
   }
   
   Service
   
   {
     "name": "servicea",
     "upstream_id": "452789772218270404"
   }
   
   upstream
   
   {
     "nodes": [
       {
         "host": "httpbin.org",
         "port": 80,
         "weight": 1
       }
     ],
     "timeout": {
       "connect": 6,
       "send": 6,
       "read": 6
     },
     "type": "roundrobin",
     "scheme": "http",
     "pass_host": "pass",
     "name": "httpbin",
     "keepalive_pool": {
       "idle_timeout": 60,
       "requests": 1000,
       "size": 320
     }
   }
   


-- 
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] soulbird commented on issue #9122: bug: plugins.proxy-rewrite does not work with path size > 2

Posted by "soulbird (via GitHub)" <gi...@apache.org>.
soulbird commented on issue #9122:
URL: https://github.com/apache/apisix/issues/9122#issuecomment-1480447075

   The configuration looks ok, is there any error log


-- 
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] Gallardot closed issue #9122: bug: plugins.proxy-rewrite does not work with path size > 2

Posted by "Gallardot (via GitHub)" <gi...@apache.org>.
Gallardot closed issue #9122: bug: plugins.proxy-rewrite does not work with path size > 2
URL: https://github.com/apache/apisix/issues/9122


-- 
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] soulbird commented on issue #9122: bug: plugins.proxy-rewrite does not work with path size > 2

Posted by "soulbird (via GitHub)" <gi...@apache.org>.
soulbird commented on issue #9122:
URL: https://github.com/apache/apisix/issues/9122#issuecomment-1478777529

   Please provide the full routing configuration, especially the `uri`. `404 route not found` usually means that there is no matching route.


-- 
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] soulbird commented on issue #9122: bug: plugins.proxy-rewrite does not work with path size > 2

Posted by "soulbird (via GitHub)" <gi...@apache.org>.
soulbird commented on issue #9122:
URL: https://github.com/apache/apisix/issues/9122#issuecomment-1486515256

   I tried to reproduce with your config, but everything seems to work fine. Below is my test case:
   ```
   use t::APISIX 'no_plan';
   
   repeat_each(1);
   no_long_string();
   no_root_location();
   no_shuffle();
   add_block_preprocessor(sub {
        my ($block) = @_;
   
        if (!$block->request) {
            $block->set_value("request", "GET /t");
        }
   });
   
   run_tests();
   
   
   __DATA__
   
   === TEST 1: config
   ---config
        location /t {
            content_by_lua_block {
                local t = require("lib.test_admin").test
   
                local code, body = t('/apisix/admin/upstreams/452789772218270404',
                     ngx.HTTP_PUT,
                     [[{ "nodes": [{ "host": "httpbin.org", "port": 80, "weight": 1 }], "timeout": { "connect": 6, "send": 6, "read": 6 }, "type": "roundrobin", "scheme": "http", "pass_host": "pass", "name": "httpbin", "keepalive_pool": { "idle_timeout": 60, "requests": 1000, "size": 320 } }]]
                    )
   
                if code > 300 then
                    return ngx.say(body)
                end
   
                code, body = t('/apisix/admin/services/452850410093281988',
                     ngx.HTTP_PUT,
                     [[{ "name": "servicea", "upstream_id": "452789772218270404" }]]
                    )
   
                if code > 300 then
                    return ngx.say(body)
                end
   
                code, body = t('/apisix/admin/routes/1',
                     ngx.HTTP_PUT,
                     [[{ "uri":"/servicea/*", "name":"route1", "methods":[ "GET", "POST", "PUT", "DELETE", "PATCH", "HEAD" , "OPTIONS", "CONNECT", "TRACE", "PURGE" ], "plugins":{ "proxy-rewrite":{ "regex_uri":[ "^/servicea/(.*)", "/${ 1}" ] } }, "service_id":"452850410093281988", "status":1 }]]
                    )
   
                if code > 300 then
                    return ngx.say(body)
                end
   
                ngx. say("passed")
            }
        }
   --- response_body
   passed
   
   
   
   === TEST 2: request
   --- pipelined_requests eval
   [
        "GET /servicea/anything", "GET /servicea/anything/123", "GET /servicea/cookies", "GET /servicea/cookies/set/john/121"
   ]
   --- error_code eval
   [
        200, 200, 200, 302
   ]
   ```


-- 
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] Gallardot commented on issue #9122: bug: plugins.proxy-rewrite does not work with path size > 2

Posted by "Gallardot (via GitHub)" <gi...@apache.org>.
Gallardot commented on issue #9122:
URL: https://github.com/apache/apisix/issues/9122#issuecomment-1478846075

   @akrjohn   Let's try it like this
   
   ```
   #Router
   
   {
       "uri":"/servicea/*",
       "name":"route1",
       "methods":[
           "GET",
           "POST",
           "PUT",
           "DELETE",
           "PATCH",
           "HEAD",
           "OPTIONS",
           "CONNECT",
           "TRACE",
           "PURGE"
       ],
       "plugins":{
           "proxy-rewrite":{
               "regex_uri":[
                   "^/servicea/(.*)",
                   "/${1}"
               ]
           }
       },
       "service_id":"452850410093281988",
       "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] akrjohn commented on issue #9122: bug: plugins.proxy-rewrite does not work with path size > 2

Posted by "akrjohn (via GitHub)" <gi...@apache.org>.
akrjohn commented on issue #9122:
URL: https://github.com/apache/apisix/issues/9122#issuecomment-1489172789

   Thanks Team will do. I also found that the host name on the upstream should be selected to node. This guarantees that i am not actually hitting example.com but the actual service. 
   I am unblocked for now. Thanks so much for looking into it.
   
   


-- 
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] tokers commented on issue #9122: bug: plugins.proxy-rewrite does not work with path size > 2

Posted by "tokers (via GitHub)" <gi...@apache.org>.
tokers commented on issue #9122:
URL: https://github.com/apache/apisix/issues/9122#issuecomment-1486554066

   > "GET /servicea/cookies/12 HTTP/1.1" 404 233 0.060 "-" "insomnia/2022.7.5" XXXXXXXXX "http://www.example.com/cookies/set/john/121"
   
   As you can, the last field is URL after the rewriting, which doesn't contain the `services` prefix. We believe the route was matched. So how did you judge the `404` is generated by Apache APISIX and is due to route not found?
   
   Addiontially, please use this URL to access your upstream directly and see if any error occurs. If you still think it's an APISIX error, try to open the flag `show_upstream_status_in_response_header` in `config-default.yaml`, which will show the upstream status in HTTP response headers.


-- 
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] akrjohn commented on issue #9122: bug: plugins.proxy-rewrite does not work with path size > 2

Posted by "akrjohn (via GitHub)" <gi...@apache.org>.
akrjohn commented on issue #9122:
URL: https://github.com/apache/apisix/issues/9122#issuecomment-1481682412

   > The configuration looks ok, is there any error log
   
   I have shared the error 
   "GET /servicea/cookies/12 HTTP/1.1" 404 233 0.060 "-" "insomnia/2022.7.5" XXXXXXXXX "http://www.example.com/cookies/set/john/121"
   
   I would really appriciate if a working config with the same httpbin as upstream can be provided for such a use case as i am not able to make it work.


-- 
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