-
Notifications
You must be signed in to change notification settings - Fork 38.5k
ForwardedHeaderFilter should allow prepend / replace depending on configuration #27739
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
Comments
A workaround is the following filter put just after |
From the previous threads, it sounds like the expected approach is to not expose the contextPath of the app behind the proxy to external clients. So the incoming URL is |
@rstoyanchev yes I understood the approach; yet I am facing a scenario not pleasant:
Hence in this scenario, using the default locator configuration of spring cloud gateway , resolution of ressource url by proxified thymeleaf fails. I have a solution based on a home made solution, yet I am not very pleased implementing framework bypass.I would rather
My point is that it is sad to have a restrictive behaviour on a border component. |
I get that you're in this scenario, and thanks for the extra detail, but the previous issue is more than 5 years old, so this doesn't seem to be very common. Taking a look at |
Closing for now but can re-open if there is more demand. |
After seeing discussion put in #18949,
Let's see the following case
Spring boot BOM version 2.5.6
Spring cloud 2020.0.4
server.servlet.context-path
set tomy-local-context-path
and seen by first application asapp-ui
in its discovery clientThe second application uses thymeleaf
@{/js/script.js}
in the template returned by the handler of/some-mvc-controller
When accessing on
http://my-gateway.url/app-ui/my-local-context-path/some-mvc-controller
/my-local-context-path/some-mvc-controller
withX-Forwarded-Prefix
set to/app-ui
ForwardedHeaderFilter
replaces http servlet request context path to/app-ui
, request uri to/app-ui/some-mvc-controller
http://my-gateway.url/app-ui/js/script.js
that ends in404
error as the correct url should have beenhttp://my-gateway.url/app-ui/my-local-context-path/js/script.js
Unless I missed something, I think that it is sad that, using all default behaviour of spring tools (but context-path) is not possible.
I would like to provide a way to let application choose between a policy of
REPLACEMENT
orPREPEND
. If none, something like setting inner classes ofForwardedHeaderFilter
asprotected
instead ofprivate
in order to let application easily implement its own policy.Before going directly to a pull request, I prefer discussing whether you're ok with that and which would be the prefered solution
protected
without any other changeserver.framework-forward-header-policy
valued toREPLACEMENT
by defaultThe text was updated successfully, but these errors were encountered: