-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add X-Forwarded-Prefix on rewrites #1805
Conversation
/lgtm |
@maxlaverse thanks! |
HI @maxlaverse ! I am trying to figure how to set this annotation on. Should it look like:
? Or there is a different syntax? |
@metaflow yes, it's a boolean but you've got the annotation wrong ( |
Thank you @pieterlange, it works! Side question: what are the translation rules from |
If the path of the url that the gw is routing to is a subset of the url that it is routing from then the difference is the prefix. Also applies if the path of the url being routed to is empty and the routed-from url path is non-empty. Included quite a few null checks as it should allow for the various different route definition styles and types of request. I've been [using this](https://github.com/ryandawsonuk/activiti-cloud-gateway/tree/develop/src/main/java/org/springframework/cloud/gateway/filter/headers) in k8s by overriding the class and found the null checks to be necessary. Was thinking it could be disabled by default as that's how it is for [nginx ingress](kubernetes/ingress-nginx#1805) but I haven't thought of any specific reason not to enable by default. fixes gh-314
If the path of the url that the gw is routing to is a subset of the url that it is routing from then the difference is the prefix. Also applies if the path of the url being routed to is empty and the routed-from url path is non-empty. Included quite a few null checks as it should allow for the various different route definition styles and types of request. I've been [using this](https://github.com/ryandawsonuk/activiti-cloud-gateway/tree/develop/src/main/java/org/springframework/cloud/gateway/filter/headers) in k8s by overriding the class and found the null checks to be necessary. Was thinking it could be disabled by default as that's how it is for [nginx ingress](kubernetes/ingress-nginx#1805) but I haven't thought of any specific reason not to enable by default. fixes gh-314
What this PR does / why we need it:
Add an annotation
x-forwarded-prefix
that activate the addition of aX-Forwarded-Prefix
to the request sent to the upstream. This prefix has the value of the Nginx location that matched the rewrite.Which issue this PR fixes
fixes #1774