Skip to content

Appending to the X-Forward-Prefix Header appends path with comma #1772

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

Closed
hgarus opened this issue Jun 10, 2020 · 5 comments
Closed

Appending to the X-Forward-Prefix Header appends path with comma #1772

hgarus opened this issue Jun 10, 2020 · 5 comments

Comments

@hgarus
Copy link

hgarus commented Jun 10, 2020

I'm currently using spring-cloud gateway behind another reverse proxy. Both strip a path component and both set an X-Forwarded-Prefix header accordingly. This leads to spring-cloud-gateway appending it's path component to the existing X-Forward-Prefix Header with both components being separated by a comma.

                                                   
Client ---/a/b/c---> Proxy1 ---- /b/c -----> Proxy2 ----- /c -----> Some Service

                       X-Forwarded-Prefix: /a      X-Forwarded-Prefix: /a,/b

This breaks Spring's ForwardedHeaderFilter, since it just uses the header's content to prefix the request path. I also couldn't find any other source describing this behaviour for X-Forwarded-Prefix - MDN describes this for X-Forwarded-For.

Some form of compatibility with Spring's ForwardedHeaderFilter (and probably other implementations which assume they can just prefix a path with the contents of X-Forwarded-Prefix would be preferable to the current behavior.

@spencergibb
Copy link
Member

We, spring, made up that header IIRC. X-Forwarded headers are cumulative. So this header behaves like other X-Forwarded headers.

@hgarus
Copy link
Author

hgarus commented Jun 10, 2020 via email

@spencergibb
Copy link
Member

That's standard multi value http headers

@hgarus
Copy link
Author

hgarus commented Jun 10, 2020

Sure, but when I see X-Forwarded-Prefix: /foo/bar,/baz upstream there is no way for me to determine if the actual path was /foo/bar,/baz or /foo/bar/baz. I'll admit it's very likely that it's the latter.

I can take this over to spring-framework, feel free to close this here.

@spencergibb
Copy link
Member

Sure, open something there and we can see what they say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants