This customizer looks at at HTTP request for headers that indicate it has been forwarded by one or more proxies. Specifically handled are
Forwarded, as defined by rfc7239
X-Forwarded-HostX-Forwarded-ServerX-Forwarded-ForX-Forwarded-ProtoX-Proxied-HttpsIf these headers are present, then the Request object is wrapped
so that the proxy is not seen as the other end point of the connection on which
the request came
Headers can also be defined so that forwarded SSL Session IDs and Cipher suites may be customised
The Authority (host and port) is updated on the Request object based
on the host / port information in the following search order.
| # | Value Origin | Host | Port | Protocol | Notes |
|---|---|---|---|---|---|
| 1 | Forwarded Header |
"host=<host>" param (Required) |
"host=<host>:<port> param (Implied) |
"proto=<value>" param (Optional) |
From left-most relevant parameter (see rfc7239) |
| 2 | X-Forwarded-Host Header |
Required | Implied | n/a | left-most value |
| 3 | X-Forwarded-Port Header |
n/a | Required | n/a | left-most value (only if getForwardedPortAsAuthority() is true) |
| 4 | X-Forwarded-Server Header |
Required | Optional | n/a | left-most value |
| 5 | X-Forwarded-Proto Header |
n/a | Implied from value | Required |
left-most value becomes protocol.
|
| 6 | X-Proxied-Https Header |
n/a | Implied from value | boolean |
left-most value determines protocol and port.
|
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private static class | |
| public static enum | ForwardedRequestCustomizer.Source
Ordered Source Enum. |
| Modifier and Type | Field and Description |
|---|---|
| private HostPortHttpField | |
| private String | |
| private String | |
| private String | |
| private String | |
| private String | |
| private boolean | |
| private String | |
| private String | |
| private String | |
| private String | |
| private final Index. | |
| private boolean | |
| private boolean | |
| private static final Logger |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Request | customize(Request request, HttpFields.
Implements org. |
| public String | |
| public String | Returns: The header name holding a forwarded cipher suite (defaultProxy-auth-cert)
|
| public String | |
| public String | |
| public String | |
| public String | Returns: The header name holding a forwarded Https status indicator (on|off true|false) (defaultX-Proxied-Https)
|
| public boolean | Returns: if true, the X-Forwarded-Port header applies to the authority, else it applies to the remote client address
|
| public String | |
| public String | Returns: the forwardedProtoHeader (defaultX-Forwarded-Proto)Get the forwardedProtoHeader. |
| public String | Returns: the header name for forwarded server.Get the header name for forwarded server.. |
| public String | Returns: The header name holding a forwarded SSL Session ID (defaultProxy-ssl-id)
|
| public String | |
| protected static String | |
| public boolean | Returns: true if the proxy address obtained viaX-Forwarded-Server or RFC7239 "by" is used as
the request authority. Default false
|
| protected static int | |
| public boolean | Returns: true if the presence of an SSL session or certificate header is sufficient to indicate a secure request (default is true)
|
| protected void | |
| public void | setForcedHost(String
The value of the host header to force. hostAndPort)Set a forced valued for the host header. |
| public void | setForwardedCipherSuiteHeader(String
The header name holding a forwarded cipher suite (default forwardedCipherSuiteHeader)Proxy-auth-cert)
|
| public void | setForwardedForHeader(String
The header name for forwarded for (default forwardedRemoteAddressHeader)X-Forwarded-For)
|
| public void | |
| public void | setForwardedHostHeader(String
The header name for forwarded hosts (default forwardedHostHeader)X-Forwarded-Host)
|
| public void | setForwardedHttpsHeader(String
the header name holding a forwarded Https status indicator(default forwardedHttpsHeader)X-Proxied-Https)Set the header name holding a forwarded Https status indicator(default |
| public void | setForwardedOnly(boolean
Configure to only support the RFC7239 Forwarded header and to
not support any rfc7239only)X-Forwarded- headers. This convenience method
clears all the non RFC headers if passed true and sets them to
the default values (if not already set) if passed false.
|
| public void | setForwardedPortAsAuthority(boolean
if true, the X-Forwarded-Port header applies to the authority,
else it applies to the remote client address forwardedPortAsAuthority)Set if the X-Forwarded-Port header will be used for Authority |
| public void | setForwardedPortHeader(String
The header name for forwarded hosts (default forwardedPortHeader)X-Forwarded-Port)
|
| public void | setForwardedProtoHeader(String
the forwardedProtoHeader to set (default forwardedProtoHeader)X-Forwarded-Proto)Set the forwardedProtoHeader. |
| public void | setForwardedServerHeader(String
The header name for forwarded server (default forwardedServerHeader)X-Forwarded-Server)
|
| public void | setForwardedSslSessionIdHeader(String
The header name holding a forwarded SSL Session ID (default forwardedSslSessionIdHeader)Proxy-ssl-id)
|
| public void | setHostHeader(String
The value of the host header to force. hostHeader)Set a forced valued for the host header. |
| public void | setProxyAsAuthority(boolean
if true, use the proxy address obtained via
proxyAsAuthority)X-Forwarded-Server or RFC7239 "by" as the request authority.
|
| public void | setSslIsSecure(boolean
true if the presence of an SSL session or certificate header is sufficient
to indicate a secure request (default is true) sslIsSecure)
|
| public String | |
| private void | |
| private void |