-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Support X-Forwarded-Prefix
#9622
Comments
As far as I understood it, it's about to append |
I didn't spend much time in analysing till now. But it would be nice if you would contribute on this one, because I will not have time to do this in the next few days. |
@ejba Hi, can you please check what is needed for |
Hi, the user is me :)
My case would work with a new property that defines which Header defines the host. Or a logik like |
@sberyozkin Yes, I can do it! So it's okay for you if I do a PR to solve both use cases? |
That would be great. How can I help? |
@kraeftbraeu well, I don't understand why CI is failing. Could you help me with that? /cc @sberyozkin |
Unfortunately that github PR checks magic is new to me, but I'll try. |
@ejba Thanks for the PR |
@sberyozkin Should X-Forwarded-Prefix be confirmed that is a valid URI? If so, what's the expected behavior here? Log a warning and ignore the header if it isn't valid? |
Hi, Since there is no standard defined for My understanding is that Traefik expects the backend to ignore the header on incoming requests but use it when constructing urls in the response, for example 301/302 redirects. Spring on the other hand seems to use the header value to dynamically append it to the context root/path on the the incoming request and use it when mapping the request to the handler code. I cannot understand why the Spring team have done their implementation in such a way and I have tried to find the original motivation but there are not that many details except for issue SPR-14270. What is the use-case when you have and external facing url that gets stripped in a reverse proxy and forwarded as a header which then gets appended back on again by the framework ? Are you sure you want to copy the Spring implementation ? :) |
Hi @atoom,
You should have a look into this issue (spring-projects/spring-framework#4732), it gives you more details about the problem. |
Hi @ejba It is the dynamic Request:
Pseudo application logic:
Response:
Maybe I have a naive/simple view of the world but to me it makes more sense to leave the incoming url as it is and only use |
So this is kinda tricky. I think you would want to apply this after the mapping layer. e.g. If you have a request for /bar with a prefix of /foo you would want to map it to the endpoint at /bar, but then modify the request so it looks like the actual URL is /foo/bar (and set the context path accordingly). We can do this with Servlet easily enough, but I don't think we can make this a generic HTTP thing, as the modification has to happen after the request has been routed. |
Hi @atoom, so there are 2 problems which are being addressed in @ejba's PR, one is to do with |
Hi @sberyozkin, I did not mean to slow up your progress on this - we have an internal discussion about this issue in our team so I was looking around various open source projects to try to find a common best practice on how this has been implemented. The way Spring have chosen to do their implementation did not fit us but when I saw that you had chosen a similar approach I was curious on your reasoning for the decision :) |
Description
My application runs behind a reverse proxy and I need to get the original path from
UriInfo
to return it as a part of theLocation
-header in a REST-resource. There already is support for severalX-Forwarded-
-headers, but not forX-Forwarded-Prefix
.It would be nice to have support for this header. Maybe it is even possible to make the header-name configurable? Because
X-Forwarded-Prefix
is not a standard and I'm using envoy, which only providesx-envoy-original-path
.I've seen that
ForwardedParser
is inspired by the Spring-solution. Spring seems to have support forX-Forwarded-Prefix
.The text was updated successfully, but these errors were encountered: