HttpHeadersFilters

HttpHeadersFilters are applied to the requests before sending them downstream, such as in the NettyRoutingFilter.

Forwarded Headers Filter

The Forwarded Headers Filter creates a Forwarded header to send to the downstream service. It adds the Host header, scheme and port of the current request to any existing Forwarded header. To activate this filter set the spring.cloud.gateway.server.webmvc.trusted-proxies property to a Java Regular Expression. This regular expression defines the proxies that are trusted when they appear in the Forwarded header.

RemoveHopByHop Headers Filter

The RemoveHopByHop Headers Filter removes headers from forwarded requests. The default list of headers that is removed comes from the IETF.

The default removed headers are:
  • Connection

  • Keep-Alive

  • Proxy-Authenticate

  • Proxy-Authorization

  • TE

  • Trailer

  • Transfer-Encoding

  • Upgrade

XForwarded Headers Filter

The XForwarded Headers Filter creates various X-Forwarded-* headers to send to the downstream service. It uses the Host header, scheme, port and path of the current request to create the various headers. To activate this filter set the spring.cloud.gateway.server.webmvc.trusted-proxies property to a Java Regular Expression. This regular expression defines the proxies that are trusted when they appear in the Forwarded header.

Creating of individual headers can be controlled by the following boolean properties (defaults to true):

  • spring.cloud.gateway.server.webmvc.x-forwarded.for-enabled

  • spring.cloud.gateway.server.webmvc.x-forwarded.host-enabled

  • spring.cloud.gateway.server.webmvc.x-forwarded.port-enabled

  • spring.cloud.gateway.server.webmvc.x-forwarded.proto-enabled

  • spring.cloud.gateway.server.webmvc.x-forwarded.prefix-enabled

Appending multiple headers can be controlled by the following boolean properties (defaults to true):

  • spring.cloud.gateway.server.webmvc.x-forwarded.for-append

  • spring.cloud.gateway.server.webmvc.x-forwarded.host-append

  • spring.cloud.gateway.server.webmvc.x-forwarded.port-append

  • spring.cloud.gateway.server.webmvc.x-forwarded.proto-append

  • spring.cloud.gateway.server.webmvc.x-forwarded.prefix-append