Properly handle proxified requests in backend services delegating to Spring-boot ForwardedHeaderFilter #119
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Properly handle proxified requests in backend services delegating to Spring-boot
ForwardedHeaderFilter
GeoServer uses a
URLMangler
extension point to make changes to exposedURL's.
To deal with proxyfied requests, it relies in a
ProxifyingUrlMangler
implementation, which can look at
X-Forwarded-*
HTTP request headersand adapt URL's accordingly.
GeoServer-cloud had its own
CloudProxifyingURLMangler
extension pointimplementation which relied on the same
X-Forwarded-*
request headers.Problem is, one of the headers Geoserver relies on is
X-Forwarded-Path
,which is an unofficial header, instead of the official
X-Forwarded-Prefix
.By setting the config property
server.forward-headers-strategy: framework
in all services
bootstrap.yml
files, we now let spring-boot'sForwardedHeaderFilter
take care of reflecting the client-originatedprotocol and address in the
HttpServletRequest
, and hence don't needthe
URLMangler
to perform proxy-related adaptations anymore.Also works when the gateway is behind another proxy, as long as it sends the
Forwarded
(and
X-Forwarded-Prefix
if needed) headers.For example, a direct request to the gateway would return:
While a proxied request would result in: