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

Regex in Routes to Capture ngx.ctx.router_matches.uri_captures disables wildcard routing #3447

Closed
rsbrisci opened this issue May 9, 2018 · 2 comments

Comments

@rsbrisci
Copy link
Contributor

rsbrisci commented May 9, 2018

Summary

While attempting to capture some parameters in a route using the following path:
["\/api\/claims\/(?<version>\\S+)"]

I ran into an issue where the wildcard routing doesn't seem to work with that regex in place.
Example:
Service URL: https://mydomain.com/api
Route Path: ["/api/claims/(?<version>\S+)"]

HTTP GET: https://mygateway.com/api/claims/v2.0/resource
routes to: https://mydomain.com/api

when it should route to
https://mycomain.com/api/resource

SUMMARY_GOES_HERE

Steps To Reproduce

  1. Create a service like:
{
"host":"mytestdomain.com",
"created_at":1525708848,
"connect_timeout":9000,
"id":"04ebc104-0029-4c66-ad67-be7d212dc9be",
"protocol":"http",
"name":"MyTestService",
"read_timeout":10000,
"port":80,
"path":"\/api",
"updated_at":1525708848,
"retries":0,
"write_timeout":10000
}
  1. Create a route like:

{
"created_at":1525708848,
"strip_path":true,
"hosts":null,
"preserve_host":false,
"regex_priority":0,
"id":"aedc7257-184b-4a58-a9a2-8cfd2dc99b0f",
"paths":[
"\/api\/claims\/(?<version>\\S+)"
],
"service":{
"id":"04ebc104-0029-4c66-ad67-be7d212dc9be"
},
"updated_at":1525708936,
"protocols":[
"http",
"https"
],
"methods":null
}
  1. Call proxy at somekonggateway.com/api/claims/v2.0/resource1/resource2
  2. Observe kong sends trraffic tomytestdomain.com/apiwithout additional params

Additional Details & Logs

  • Kong version ($ kong version) 0.13.1
  • Operating System: Kong Alpine Docker
@rsbrisci
Copy link
Contributor Author

rsbrisci commented May 9, 2018

UPDATE:

Appears to be the case only if the regex field is the final path parameter in the PATH.
so a PATH of /api/claim/(?<version>\S+)/test will route as expected.

@rsbrisci
Copy link
Contributor Author

rsbrisci commented May 9, 2018

RESOLVED:
We fixed it with this path:
\/api\/claims\/v(?<version>\\d+.\\d+)\/* - this routes as expected

@rsbrisci rsbrisci closed this as completed May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant