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.
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 | getForwardedCipherSuiteHeader()
Returns: The header name holding a forwarded cipher suite (default |
| public String | |
| public String | |
| public String | |
| public String | getForwardedHttpsHeader()
Returns: The header name holding a forwarded Https status indicator (on|off true|false) (default |
| public boolean | getForwardedPortAsAuthority()
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 | getForwardedSslSessionIdHeader()
Returns: The header name holding a forwarded SSL Session ID (default |
| public String | |
| protected static String | |
| public boolean | getProxyAsAuthority()
Returns: true if the proxy address obtained via
|
| protected static int | |
| public boolean | isSslIsSecure()
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 |
| _forcedHost | back to summary |
|---|---|
| private HostPortHttpField _forcedHost | |
| _forwardedCipherSuiteHeader | back to summary |
|---|---|
| private String _forwardedCipherSuiteHeader | |
| _forwardedForHeader | back to summary |
|---|---|
| private String _forwardedForHeader | |
| _forwardedHeader | back to summary |
|---|---|
| private String _forwardedHeader | |
| _forwardedHostHeader | back to summary |
|---|---|
| private String _forwardedHostHeader | |
| _forwardedHttpsHeader | back to summary |
|---|---|
| private String _forwardedHttpsHeader | |
| _forwardedPortAsAuthority | back to summary |
|---|---|
| private boolean _forwardedPortAsAuthority | |
| _forwardedPortHeader | back to summary |
|---|---|
| private String _forwardedPortHeader | |
| _forwardedProtoHeader | back to summary |
|---|---|
| private String _forwardedProtoHeader | |
| _forwardedServerHeader | back to summary |
|---|---|
| private String _forwardedServerHeader | |
| _forwardedSslSessionIdHeader | back to summary |
|---|---|
| private String _forwardedSslSessionIdHeader | |
| _handles | back to summary |
|---|---|
| private final Index. | |
| _proxyAsAuthority | back to summary |
|---|---|
| private boolean _proxyAsAuthority | |
| _sslIsSecure | back to summary |
|---|---|
| private boolean _sslIsSecure | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| ForwardedRequestCustomizer | back to summary |
|---|---|
| public ForwardedRequestCustomizer() | |
| customize | back to summary |
|---|---|
| public Request customize(Request request, HttpFields. Implements org.
| |
| getForcedHost | back to summary |
|---|---|
| public String getForcedHost() | |
| getForwardedCipherSuiteHeader | back to summary |
|---|---|
public String getForwardedCipherSuiteHeader()
| |
| getForwardedForHeader | back to summary |
|---|---|
| public String getForwardedForHeader() Get the forwarded for header.
| |
| getForwardedHeader | back to summary |
|---|---|
public String getForwardedHeader()
| |
| getForwardedHostHeader | back to summary |
|---|---|
| public String getForwardedHostHeader() | |
| getForwardedHttpsHeader | back to summary |
|---|---|
public String getForwardedHttpsHeader()
| |
| getForwardedPortAsAuthority | back to summary |
|---|---|
public boolean getForwardedPortAsAuthority()
| |
| getForwardedPortHeader | back to summary |
|---|---|
| public String getForwardedPortHeader() | |
| getForwardedProtoHeader | back to summary |
|---|---|
| public String getForwardedProtoHeader() Get the forwardedProtoHeader.
| |
| getForwardedServerHeader | back to summary |
|---|---|
| public String getForwardedServerHeader() Get the header name for forwarded server..
| |
| getForwardedSslSessionIdHeader | back to summary |
|---|---|
public String getForwardedSslSessionIdHeader()
| |
| getHostHeader | back to summary |
|---|---|
| public String getHostHeader() | |
| getLeftMost | back to summary |
|---|---|
| protected static String getLeftMost(String headerValue) | |
| getProxyAsAuthority | back to summary |
|---|---|
public boolean getProxyAsAuthority()
| |
| getSecurePort | back to summary |
|---|---|
| protected static int getSecurePort(HttpConfiguration config) | |
| isSslIsSecure | back to summary |
|---|---|
public boolean isSslIsSecure()
| |
| onError | back to summary |
|---|---|
| protected void onError(HttpField field, Throwable t) | |
| setForcedHost | back to summary |
|---|---|
| public void setForcedHost(String hostAndPort) Set a forced valued for the host header.
| |
| setForwardedCipherSuiteHeader | back to summary |
|---|---|
public void setForwardedCipherSuiteHeader(String forwardedCipherSuiteHeader)
| |
| setForwardedForHeader | back to summary |
|---|---|
public void setForwardedForHeader(String forwardedRemoteAddressHeader)
| |
| setForwardedHeader | back to summary |
|---|---|
public void setForwardedHeader(String forwardedHeader)
| |
| setForwardedHostHeader | back to summary |
|---|---|
public void setForwardedHostHeader(String forwardedHostHeader)
| |
| setForwardedHttpsHeader | back to summary |
|---|---|
| public void setForwardedHttpsHeader(String forwardedHttpsHeader) Set the header name holding a forwarded Https status indicator(default
| |
| setForwardedOnly | back to summary |
|---|---|
public void setForwardedOnly(boolean rfc7239only)
| |
| setForwardedPortAsAuthority | back to summary |
|---|---|
| public void setForwardedPortAsAuthority(boolean forwardedPortAsAuthority) Set if the X-Forwarded-Port header will be used for Authority
| |
| setForwardedPortHeader | back to summary |
|---|---|
public void setForwardedPortHeader(String forwardedPortHeader)
| |
| setForwardedProtoHeader | back to summary |
|---|---|
| public void setForwardedProtoHeader(String forwardedProtoHeader) Set the forwardedProtoHeader.
| |
| setForwardedServerHeader | back to summary |
|---|---|
public void setForwardedServerHeader(String forwardedServerHeader)
| |
| setForwardedSslSessionIdHeader | back to summary |
|---|---|
public void setForwardedSslSessionIdHeader(String forwardedSslSessionIdHeader)
| |
| setHostHeader | back to summary |
|---|---|
| public void setHostHeader(String hostHeader) Set a forced valued for the host header.
| |
| setProxyAsAuthority | back to summary |
|---|---|
public void setProxyAsAuthority(boolean proxyAsAuthority)
| |
| setSslIsSecure | back to summary |
|---|---|
public void setSslIsSecure(boolean sslIsSecure)
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| updateForwardedHandle | back to summary |
|---|---|
| private void updateForwardedHandle(MethodHandles. | |
| updateHandles | back to summary |
|---|---|
| private void updateHandles() | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv ForwardedRequestCustomizer. | |
| pack-priv HttpConfiguration | |
| pack-priv ForwardedRequestCustomizer. | |
| pack-priv String | |
| pack-priv ForwardedRequestCustomizer. | |
| pack-priv Request | |
| pack-priv Boolean | |
| pack-priv boolean | |
| pack-priv EndPoint. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private ForwardedRequestCustomizer. | |
| private ForwardedRequestCustomizer. | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public boolean | |
| public boolean | |
| protected void | parsedParam(StringBuffer
Containing the trimmed value and all parameters, which may be mutated buffer, int The length of the value valueLength, int The index of the start of the parameter just parsed paramName, int The index of the start of the parameter value just parsed, or -1 paramValue)Overrides org. Called when a parameter has been parsed |
| public String | |
| private void | |
| private void | |
| private void |
| _authority | back to summary |
|---|---|
| pack-priv ForwardedRequestCustomizer. | |
| _config | back to summary |
|---|---|
| pack-priv HttpConfiguration _config | |
| _for | back to summary |
|---|---|
| pack-priv ForwardedRequestCustomizer. | |
| _proto | back to summary |
|---|---|
| pack-priv String _proto | |
| _protoSource | back to summary |
|---|---|
| pack-priv ForwardedRequestCustomizer. | |
| _request | back to summary |
|---|---|
| pack-priv Request _request | |
| _secure | back to summary |
|---|---|
| pack-priv Boolean _secure | |
| _secureScheme | back to summary |
|---|---|
| pack-priv boolean _secureScheme | |
| _sslSessionData | back to summary |
|---|---|
| pack-priv EndPoint. | |
| Forwarded | back to summary |
|---|---|
| public Forwarded(Request request, HttpConfiguration config) | |
| getAuthority | back to summary |
|---|---|
| private ForwardedRequestCustomizer. | |
| getFor | back to summary |
|---|---|
| private ForwardedRequestCustomizer. | |
| handleCipherSuite | back to summary |
|---|---|
| public void handleCipherSuite(HttpField field) Called if header is | |
| handleForwardedFor | back to summary |
|---|---|
| public void handleForwardedFor(HttpField field) Called if header is | |
| handleForwardedHost | back to summary |
|---|---|
| public void handleForwardedHost(HttpField field) Called if header is | |
| handleForwardedPort | back to summary |
|---|---|
| public void handleForwardedPort(HttpField field) Called if header is | |
| handleForwardedServer | back to summary |
|---|---|
| public void handleForwardedServer(HttpField field) Called if header is | |
| handleHttps | back to summary |
|---|---|
| public void handleHttps(HttpField field) Called if header is | |
| handleProto | back to summary |
|---|---|
| public void handleProto(HttpField field) Called if header is | |
| handleRFC7239 | back to summary |
|---|---|
| public void handleRFC7239(HttpField field) Called if header is | |
| handleSslSessionId | back to summary |
|---|---|
| public void handleSslSessionId(HttpField field) Called if header is | |
| hasFor | back to summary |
|---|---|
| public boolean hasFor() | |
| isSecure | back to summary |
|---|---|
| public boolean isSecure() | |
| parsedParam | back to summary |
|---|---|
| protected void parsedParam(StringBuffer buffer, int valueLength, int paramName, int paramValue) Overrides org. Doc from org. Called when a parameter has been parsed
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| updateAuthority | back to summary |
|---|---|
| private void updateAuthority(String value, ForwardedRequestCustomizer. | |
| updatePort | back to summary |
|---|---|
| private void updatePort(int port, ForwardedRequestCustomizer. | |
| updateProto | back to summary |
|---|---|
| private void updateProto(String proto, ForwardedRequestCustomizer. | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv String | |
| pack-priv ForwardedRequestCustomizer. | |
| pack-priv int | |
| pack-priv ForwardedRequestCustomizer. | |
| public static final int | |
| public static final int |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | |
| public void | |
| public String |
| _host | back to summary |
|---|---|
| pack-priv String _host | |
| _hostSource | back to summary |
|---|---|
| pack-priv ForwardedRequestCustomizer. | |
| _port | back to summary |
|---|---|
| pack-priv int _port | |
| _portSource | back to summary |
|---|---|
| pack-priv ForwardedRequestCustomizer. | |
| IMPLIED | back to summary |
|---|---|
| public static final int IMPLIED | |
| UNSET | back to summary |
|---|---|
| public static final int UNSET | |
| MutableHostPort | back to summary |
|---|---|
| private MutableHostPort() | |
| setHost | back to summary |
|---|---|
| public void setHost(String host, ForwardedRequestCustomizer. | |
| setHostPort | back to summary |
|---|---|
| public void setHostPort(String host, int port, ForwardedRequestCustomizer. | |
| setHostPort | back to summary |
|---|---|
| public void setHostPort(HostPort hostPort, ForwardedRequestCustomizer. | |
| setPort | back to summary |
|---|---|
| public void setPort(int port, ForwardedRequestCustomizer. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
Lowest first, Last/Highest priority wins
| Modifier and Type | Field and Description |
|---|---|
| public static final ForwardedRequestCustomizer. | |
| public static final ForwardedRequestCustomizer. | |
| public static final ForwardedRequestCustomizer. | |
| public static final ForwardedRequestCustomizer. | |
| public static final ForwardedRequestCustomizer. | |
| public static final ForwardedRequestCustomizer. | |
| public static final ForwardedRequestCustomizer. | |
| public static final ForwardedRequestCustomizer. | |
| public static final ForwardedRequestCustomizer. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv int | |
| public static ForwardedRequestCustomizer. | |
| public static ForwardedRequestCustomizer. |
| FORCED | back to summary |
|---|---|
| public static final ForwardedRequestCustomizer. | |
| FORWARDED | back to summary |
|---|---|
| public static final ForwardedRequestCustomizer. | |
| UNSET | back to summary |
|---|---|
| public static final ForwardedRequestCustomizer. | |
| XFORWARDED_FOR | back to summary |
|---|---|
| public static final ForwardedRequestCustomizer. | |
| XFORWARDED_HOST | back to summary |
|---|---|
| public static final ForwardedRequestCustomizer. | |
| XFORWARDED_PORT | back to summary |
|---|---|
| public static final ForwardedRequestCustomizer. | |
| XFORWARDED_PROTO | back to summary |
|---|---|
| public static final ForwardedRequestCustomizer. | |
| XFORWARDED_SERVER | back to summary |
|---|---|
| public static final ForwardedRequestCustomizer. | |
| XPROXIED_HTTPS | back to summary |
|---|---|
| public static final ForwardedRequestCustomizer. | |
| Source | back to summary |
|---|---|
| private Source() | |
| priority | back to summary |
|---|---|
| pack-priv int priority() | |
| valueOf | back to summary |
|---|---|
| public static ForwardedRequestCustomizer. | |
| values | back to summary |
|---|---|
| public static ForwardedRequestCustomizer. | |