- java.lang.Object
-
- io.vertx.httpproxy.ForwardedHeadersOptions
-
public class ForwardedHeadersOptions extends Object
Options for configuring forwarded headers support in the proxy.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 7239Forwardedheader.
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_ENABLEDDefault enabled =falsestatic booleanDEFAULT_FORWARD_FORDefault forward for =truestatic booleanDEFAULT_FORWARD_HOSTDefault forward host =truestatic booleanDEFAULT_FORWARD_PORTDefault forward port =truestatic booleanDEFAULT_FORWARD_PROTODefault forward proto =truestatic booleanDEFAULT_USE_RFC7239Default use RFC 7239 =false
-
Constructor Summary
Constructors Constructor Description ForwardedHeadersOptions()Default constructor.ForwardedHeadersOptions(JsonObject json)Constructor to create an options from JSON.ForwardedHeadersOptions(ForwardedHeadersOptions other)Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisEnabled()booleanisForwardFor()booleanisForwardHost()booleanisForwardPort()booleanisForwardProto()booleanisUseRfc7239()ForwardedHeadersOptionssetEnabled(boolean enabled)Set whether forwarded headers support is enabled.ForwardedHeadersOptionssetForwardFor(boolean forwardFor)Set whether to forward the client IP address.ForwardedHeadersOptionssetForwardHost(boolean forwardHost)Set whether to forward the original host.ForwardedHeadersOptionssetForwardPort(boolean forwardPort)Set whether to forward the original port.ForwardedHeadersOptionssetForwardProto(boolean forwardProto)Set whether to forward the original protocol (http/https).ForwardedHeadersOptionssetUseRfc7239(boolean useRfc7239)Set whether to use RFC 7239 Forwarded header instead ofX-Forwarded-*headers.JsonObjecttoJson()Convert to JSON.StringtoString()
-
-
-
Field Detail
-
DEFAULT_ENABLED
public static final boolean DEFAULT_ENABLED
Default enabled =false- See Also:
- Constant Field Values
-
DEFAULT_FORWARD_FOR
public static final boolean DEFAULT_FORWARD_FOR
Default forward for =true- See Also:
- Constant Field Values
-
DEFAULT_FORWARD_PROTO
public static final boolean DEFAULT_FORWARD_PROTO
Default forward proto =true- See Also:
- Constant Field Values
-
DEFAULT_FORWARD_HOST
public static final boolean DEFAULT_FORWARD_HOST
Default forward host =true- See Also:
- Constant Field Values
-
DEFAULT_FORWARD_PORT
public static final boolean DEFAULT_FORWARD_PORT
Default forward port =true- See Also:
- Constant Field Values
-
DEFAULT_USE_RFC7239
public static final boolean DEFAULT_USE_RFC7239
Default use RFC 7239 =false- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ForwardedHeadersOptions
public ForwardedHeadersOptions()
Default constructor.
-
ForwardedHeadersOptions
public ForwardedHeadersOptions(ForwardedHeadersOptions other)
Copy constructor.- Parameters:
other- the options to copy
-
ForwardedHeadersOptions
public ForwardedHeadersOptions(JsonObject json)
Constructor to create an options from JSON.- Parameters:
json- the JSON
-
-
Method Detail
-
isEnabled
public boolean isEnabled()
- Returns:
- whether forwarded headers support is enabled
-
setEnabled
public ForwardedHeadersOptions setEnabled(boolean enabled)
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
public ForwardedHeadersOptions setForwardFor(boolean forwardFor)
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
public ForwardedHeadersOptions setForwardProto(boolean forwardProto)
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
public ForwardedHeadersOptions setForwardHost(boolean forwardHost)
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
public ForwardedHeadersOptions setForwardPort(boolean forwardPort)
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
public ForwardedHeadersOptions setUseRfc7239(boolean useRfc7239)
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
-
toJson
public JsonObject toJson()
Convert to JSON.- Returns:
- the JSON
-
-