Giter Club home page Giter Club logo

Comments (7)

jakub-bochenski avatar jakub-bochenski commented on May 24, 2024

It seems that \d+ in path is working like .+

tyk-gateway_1  | time="Oct 05 15:45:02" level=debug msg=Started api_id=search api_name=Search mw=VersionCheck org_id=default origin=172.19.0.1 path=/search/v1/abc ts=1696520702660512538
tyk-gateway_1  | time="Oct 05 15:45:02" level=debug msg=Finished api_id=search api_name=Search code=200 mw=VersionCheck ns=57338 org_id=default origin=172.19.0.1 path=/search/v1/abc

What gives?

Only by changing the path to sth like `"(\d+)/foo" I can observe requests being rejected

from tyk.

jakub-bochenski avatar jakub-bochenski commented on May 24, 2024

Same with "\\d+/" and "[0-9]+/"

from tyk.

jakub-bochenski avatar jakub-bochenski commented on May 24, 2024

It seems to be some problem with single-component paths, since if I do "[0-9]+/foo" it works as expected

tyk-gateway_1  | time="Oct 05 16:35:52" level=debug msg=Started api_id=search api_name=Search mw=VersionCheck org_id=default origin=172.19.0.1 path=/search/v1/abcd/foo ts=1696523752943944511
tyk-gateway_1  | time="Oct 05 16:35:52" level=debug msg="EVENT FIRED: VersionFailure"
tyk-gateway_1  | time="Oct 05 16:35:52" level=debug msg=Finished api_id=search api_name=Search code=403 error="Requested endpoint is forbidden" mw=VersionCheck ns=135375 org_id=default origin=172.19.0.1 path=/search/v1/abcd/foo
tyk-gateway_1  | time="Oct 05 16:36:10" level=debug msg=Started api_id=search api_name=Search mw=VersionCheck org_id=default origin=172.19.0.1 path=/search/v1/30602/foo ts=1696523770610129310
tyk-gateway_1  | time="Oct 05 16:36:10" level=debug msg=Finished api_id=search api_name=Search code=200 mw=VersionCheck ns=61352 org_id=default origin=172.19.0.1 path=/search/v1/30602/foo

from tyk.

jakub-bochenski avatar jakub-bochenski commented on May 24, 2024

Without the url_rewrites it get's even weirder.
Why is the version component not stripped from the upstream path?!

tyk-gateway_1  | time="Oct 05 17:02:59" level=debug msg=Started api_id=search api_name=Search mw=VersionCheck org_id=default origin=172.19.0.1 path=/search/v1/abcd ts=1696525379064344695
tyk-gateway_1  | time="Oct 05 17:02:59" level=debug msg=Finished api_id=search api_name=Search code=200 mw=VersionCheck ns=44317 org_id=default origin=172.19.0.1 path=/search/v1/abcd
tyk-gateway_1  | time="Oct 05 17:02:59" level=debug msg=Started api_id=search api_name=Search mw=RateCheckMW org_id=default origin=172.19.0.1 path=/search/v1/abcd ts=1696525379064404263
tyk-gateway_1  | time="Oct 05 17:02:59" level=debug msg=Finished api_id=search api_name=Search code=200 mw=RateCheckMW ns=24484 org_id=default origin=172.19.0.1 path=/search/v1/abcd
tyk-gateway_1  | time="Oct 05 17:02:59" level=debug msg="Started proxy"
tyk-gateway_1  | time="Oct 05 17:02:59" level=debug msg="Stripping proxy listen path: /search/"
tyk-gateway_1  | time="Oct 05 17:02:59" level=debug msg="Upstream path is: /v1/abcd"
tyk-gateway_1  | time="Oct 05 17:02:59" level=debug msg=Started api_id=search api_name=Search mw=ReverseProxy org_id=default ts=1696525379064455195
tyk-gateway_1  | time="Oct 05 17:02:59" level=debug msg="Upstream request URL: /v1/abcd" api_id=search api_name=Search mw=ReverseProxy org_id=default
tyk-gateway_1  | time="Oct 05 17:02:59" level=debug msg="Outbound request URL: https://httpbin.org/anything/v1/abcd" api_id=search api_name=Search mw=ReverseProxy org_id=default
tyk-gateway_1  | time="Oct 05 17:02:59" level=debug msg="Creating new transport" api_id=search api_name=Search mw=ReverseProxy org_id=default
tyk-gateway_1  | time="Oct 05 17:02:59" level=debug msg="Out request url: https://httpbin.org/anything/v1/abcd" api_id=search api_name=Search mw=ReverseProxy org_id=default
tyk-gateway_1  | time="Oct 05 17:03:00" level=debug msg=Finished api_id=search api_name=Search mw=ReverseProxy ns=1021647467 org_id=default

from tyk.

jakub-bochenski avatar jakub-bochenski commented on May 24, 2024

Also notice the rewrite is somehow capturing abcd into a (\d+) capturing group as 1

tyk-gateway_1  | time="Oct 05 16:57:23" level=debug msg="Rewriter checking matches, len is: 1"
tyk-gateway_1  | time="Oct 05 16:57:23" level=debug msg="[[1 1]]"
tyk-gateway_1  | time="Oct 05 16:57:23" level=debug msg="[[$1]]"
tyk-gateway_1  | time="Oct 05 16:57:23" level=debug msg="URL Re-written from: /search/v1/abcd"
tyk-gateway_1  | time="Oct 05 16:57:23" level=debug msg="URL Re-written to: gateway?projectId=1"

from tyk.

jakub-bochenski avatar jakub-bochenski commented on May 24, 2024

It appears that to get what I want I need to specify "path": "^/search/v1/[0-9]+$" as regex.

This seems bad, as it forces me to repeat the listen_path and version prefix in every regex.

This is both bloat and makes it hard to reuse the statements for a different listen path or version

from tyk.

jakub-bochenski avatar jakub-bochenski commented on May 24, 2024

Closed in favour of #5601

from tyk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.