Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy doesn't always respect "strip_uri" with multiple "uris" #2562

Closed
sgillespie opened this issue May 25, 2017 · 5 comments
Closed

Proxy doesn't always respect "strip_uri" with multiple "uris" #2562

sgillespie opened this issue May 25, 2017 · 5 comments
Labels
task/needs-investigation Requires investigation and reproduction before classifying it as a bug or not.

Comments

@sgillespie
Copy link

sgillespie commented May 25, 2017

Summary

If I define an API with multiple URIs, and strip_uri = true, Kong doesn't always strip the matching prefix. When I first start Kong, it works with both URIs, then one of them stripping the prefix. Full example below.

Steps To Reproduce

  1. Start a kong:0.10.2 docker image

    # Start Postgres
    docker run -d --name kong-database \
        -p 9042:9042 \
        cassandra:2.2
    
    # Start nginx
    docker run -d -p 80:80 --name nginx nginx
    
    # Start Kong
    docker run -d --name kong \
       --link kong-database:kong-database --link nginx:nginx \
       -e "KONG_DATABASE=postgres" \
       -e "KONG_PG_HOST=kong-database" \
       -p 8000:8000 \
       -p 8443:8443 \
       -p 8001:8001 \
       -p 7946:7946 \
       -p 7946:7946/udp \
       kong:0.10.2
    
  2. Add an API with multiple URIs

    curl -H 'Content-Type: application/json' \
        -X POST \
        -d '{ "name": "nginx", "uris": ["/x/y/z", "/z/y/x"], "upstream_url": "http://nginx", "strip_uri": true}' \
        http://localhost:8001/apis           
    
  3. Request the API in both forms multiple times (it will eventually start happening)

    curl http://localhost:8000/x/y/z/a/b/c
    curl http://localhost:8000/z/y/x/a/b/c
    curl http://localhost:8000/x/y/z/a/b/c
    curl http://localhost:8000/z/y/x/a/b/c
    curl http://localhost:8000/x/y/z/a/b/c
    curl http://localhost:8000/z/y/x/a/b/c
    
  4. Check the nginx logs (404s are expected):

    docker logs -f nginx

    172.17.0.4 - - [25/May/2017:13:53:24 +0000] "GET /a/b/c
    172.17.0.4 - - [25/May/2017:13:53:33 +0000] "GET /a/b/c
    172.17.0.4 - - [25/May/2017:13:53:41 +0000] "GET /a/b/c
    172.17.0.4 - - [25/May/2017:13:53:45 +0000] "GET /a/b/c
    172.17.0.4 - - [25/May/2017:13:53:50 +0000] "GET /x/y/z/a/b/c

You can see above that it eventually stops stripping the prefix on /x/y/z. However, /z/y/x still works as expected

Additional Details & Logs

  • Kong version: 0.10.2 (Also tested on 0.10.1 and "latest")
  • Operating System: ArchLinux (vanilla kernel 4.10.13) and Docker 17.05.0-ce
@thibaultcha
Copy link
Member

Hi,

Thanks for the report, we'll be looking into it.

@thibaultcha thibaultcha added the task/needs-investigation Requires investigation and reproduction before classifying it as a bug or not. label May 30, 2017
thibaultcha added a commit that referenced this issue May 31, 2017
Because of our Lua-land LRU cache, we used not to execute `match_api`,
which takes care of discovering which configured uri matched a given
API, and should be stripped.

This operation is O(1) for plain text URIs, as well as hosts and
methods, hence, we do not suffer any performance penalty.

Fix #2562
@thibaultcha
Copy link
Member

Fix proposed in #2582!

@thibaultcha
Copy link
Member

This will be released in 0.10.4 or 0.11.0. Thanks again for the report!

@marccardinal
Copy link

Currently affected by this, do you have a nightly build of the kong container that would contain this fix?

@thibaultcha
Copy link
Member

No, sorry.

thibaultcha added a commit that referenced this issue Oct 19, 2017
Because of our Lua-land LRU cache, we used not to execute `match_api`,
which takes care of discovering which configured uri matched a given
API, and should be stripped.

This operation is O(1) for plain text URIs, as well as hosts and
methods, hence, we do not suffer any performance penalty.

Fix #2562
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task/needs-investigation Requires investigation and reproduction before classifying it as a bug or not.
Projects
None yet
Development

No branches or pull requests

3 participants