Class ForwardedHeadersOptions
These headers are used to preserve information about the original client request when proxying through one or more intermediaries.
The proxy can add either X-Forwarded-* headers (de-facto standard) or the RFC 7239 Forwarded header.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanDefault enabled =falsestatic final booleanDefault forward for =truestatic final booleanDefault forward host =truestatic final booleanDefault forward port =truestatic final booleanDefault forward proto =truestatic final booleanDefault use RFC 7239 =false -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Constructor to create an options from JSON.Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanbooleanbooleanbooleanbooleansetEnabled(boolean enabled) Set whether forwarded headers support is enabled.setForwardFor(boolean forwardFor) Set whether to forward the client IP address.setForwardHost(boolean forwardHost) Set whether to forward the original host.setForwardPort(boolean forwardPort) Set whether to forward the original port.setForwardProto(boolean forwardProto) Set whether to forward the original protocol (http/https).setUseRfc7239(boolean useRfc7239) Set whether to use RFC 7239 Forwarded header instead ofX-Forwarded-*headers.toJson()Convert to JSON.toString()
-
Field Details
-
DEFAULT_ENABLED
public static final boolean DEFAULT_ENABLEDDefault enabled =false- See Also:
-
DEFAULT_FORWARD_FOR
public static final boolean DEFAULT_FORWARD_FORDefault forward for =true- See Also:
-
DEFAULT_FORWARD_PROTO
public static final boolean DEFAULT_FORWARD_PROTODefault forward proto =true- See Also:
-
DEFAULT_FORWARD_HOST
public static final boolean DEFAULT_FORWARD_HOSTDefault forward host =true- See Also:
-
DEFAULT_FORWARD_PORT
public static final boolean DEFAULT_FORWARD_PORTDefault forward port =true- See Also:
-
DEFAULT_USE_RFC7239
public static final boolean DEFAULT_USE_RFC7239Default use RFC 7239 =false- See Also:
-
-
Constructor Details
-
ForwardedHeadersOptions
public ForwardedHeadersOptions()Default constructor. -
ForwardedHeadersOptions
Copy constructor.- Parameters:
other- the options to copy
-
ForwardedHeadersOptions
Constructor to create an options from JSON.- Parameters:
json- the JSON
-
-
Method Details
-
isEnabled
public boolean isEnabled()- Returns:
- whether forwarded headers support is enabled
-
setEnabled
Set whether forwarded headers support is enabled.When disabled, no forwarded headers will be added to proxied requests.
- Parameters:
enabled-trueto enable forwarded headers- Returns:
- a reference to this, so the API can be used fluently
-
isForwardFor
public boolean isForwardFor()- Returns:
- whether to forward client IP address
-
setForwardFor
Set whether to forward the client IP address.When enabled, adds the
X-Forwarded-Forheader (or the 'for' parameter in RFC 7239 Forwarded header) with the client's IP address. If the header already exists, the client IP is appended to preserve the proxy chain.- Parameters:
forwardFor-trueto forward client IP- Returns:
- a reference to this, so the API can be used fluently
-
isForwardProto
public boolean isForwardProto()- Returns:
- whether to forward the original protocol (http/https)
-
setForwardProto
Set whether to forward the original protocol (http/https).When enabled, adds the
X-Forwarded-Protoheader (or the 'proto' parameter in RFC 7239 Forwarded header) with the original request scheme.- Parameters:
forwardProto-trueto forward protocol- Returns:
- a reference to this, so the API can be used fluently
-
isForwardHost
public boolean isForwardHost()- Returns:
- whether to forward the original host
-
setForwardHost
Set whether to forward the original host.When enabled, adds the
X-Forwarded-Hostheader (or the 'host' parameter in RFC 7239 Forwarded header) with the original request host. This is only added if the host was not already set byProxyRequest.setAuthority(io.vertx.core.net.HostAndPort).- Parameters:
forwardHost-trueto forward host- Returns:
- a reference to this, so the API can be used fluently
-
isForwardPort
public boolean isForwardPort()- Returns:
- whether to forward the original port
-
setForwardPort
Set whether to forward the original port.When enabled, adds the
X-Forwarded-Portheader with the original request port. This parameter is not included in RFC 7239 Forwarded header.- Parameters:
forwardPort-trueto forward port- Returns:
- a reference to this, so the API can be used fluently
-
isUseRfc7239
public boolean isUseRfc7239()- Returns:
- whether to use RFC 7239 Forwarded header instead of
X-Forwarded-*headers
-
setUseRfc7239
Set whether to use RFC 7239 Forwarded header instead ofX-Forwarded-*headers.When enabled, uses the standardized
Forwardedheader instead of the de-factoX-Forwarded-For,X-Forwarded-Proto, andX-Forwarded-Hostheaders. TheX-Forwarded-Portheader is not included in RFC 7239.- Parameters:
useRfc7239-trueto use RFC 7239 format- Returns:
- a reference to this, so the API can be used fluently
-
toString
-
toJson
-