Improve docs on forwarded headers
Issue: SPR-16660
This commit is contained in:
@@ -854,6 +854,44 @@ views through the <<webflux-config-view-resolvers,WebFlux Config>>. Default view
|
||||
always selected and used if they match the requested media type.
|
||||
|
||||
|
||||
[[webflux-filters]]
|
||||
== Filters
|
||||
[.small]#<<web.adoc#filters,Same in Spring MVC>>#
|
||||
|
||||
As part of the <<webflux-web-handler-api>>, the `spring-web` module provides a number of
|
||||
`WebFilter` implementations.
|
||||
|
||||
|
||||
|
||||
[[webflux-filters-forwarded-headers]]
|
||||
=== Forwarded Headers
|
||||
[.small]#<<web.adoc#filters-forwarded-headers,Same in Spring MVC>>#
|
||||
|
||||
As a request goes through proxies such as load balancers the host, port, and
|
||||
scheme may change presenting a challenge for applications that need to create links
|
||||
to resources since the links should reflect the host, port, and scheme of the
|
||||
original request as seen from a client perspective.
|
||||
|
||||
https://tools.ietf.org/html/rfc7239[RFC 7239] defines the "Forwarded" HTTP header
|
||||
for proxies to use to provide information about the original request. There are also
|
||||
other non-standard headers in use such as "X-Forwarded-Host", "X-Forwarded-Port",
|
||||
and "X-Forwarded-Proto".
|
||||
|
||||
`ForwardedHeaderFilter` detects, extracts, and uses information from the "Forwarded"
|
||||
header, or from "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto".
|
||||
It wraps the request in order to overlay its host, port, and scheme and also "hides"
|
||||
the forwarded headers for subsequent processing.
|
||||
|
||||
Note that there are security considerations when using forwarded headers as explained
|
||||
in Section 8 of RFC 7239. At the application level it is difficult to determine whether
|
||||
forwarded headers can be trusted or not. This is why the network upstream should be
|
||||
configured correctly to filter out untrusted forwarded headers from the outside.
|
||||
|
||||
Applications that don't have a proxy and don't need to use forwarded headers can
|
||||
configure the `ForwardedHeaderFilter` to remove and ignore such headers.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[[webflux-controller]]
|
||||
|
||||
@@ -1029,6 +1029,7 @@ Once the Servlet 3.0 configuration is in place, simply add a bean of type
|
||||
|
||||
[[filters]]
|
||||
== Filters
|
||||
[.small]#<<web-reactive.adoc#webflux-filters,Same in Spring WebFlux>>#
|
||||
|
||||
The `spring-web` module provides some useful filters.
|
||||
|
||||
@@ -1048,8 +1049,9 @@ available through the `ServletRequest.getParameter{asterisk}()` family of method
|
||||
|
||||
|
||||
|
||||
[[filters-forwarded-headers]]
|
||||
[[webflux-filters-forwarded-headers]]
|
||||
=== Forwarded Headers
|
||||
[.small]#<<web-reactive.adoc#webflux-filters-forwarded-headers,Same in Spring WebFlux>>#
|
||||
|
||||
As a request goes through proxies such as load balancers the host, port, and
|
||||
scheme may change presenting a challenge for applications that need to create links
|
||||
|
||||
Reference in New Issue
Block a user