public class ReverseProxyBuilder extends Object implements io.muserver.MuHandlerBuilder<ReverseProxy>
MuHandler that can be added to a Mu Server.| Constructor and Description |
|---|
ReverseProxyBuilder() |
| Modifier and Type | Method and Description |
|---|---|
ReverseProxyBuilder |
addProxyCompleteListener(ProxyCompleteListener proxyCompleteListener)
Registers a proxy completion listener.
|
ReverseProxy |
build()
Creates a new ReverseProxy which is a MuHandler.
|
ReverseProxyBuilder |
discardClientForwardedHeaders(boolean discardClientForwardedHeaders)
If true, then any
Forwarded or X-Forwarded-* headers that are sent
from the client to this reverse proxy will be dropped (defaults to false). |
ReverseProxyBuilder |
proxyHostHeader(boolean sendHostToTarget)
Specifies whether or not to send the original
Host header to the target server. |
static ReverseProxyBuilder |
reverseProxy()
Creates and returns a new instance of a reverse proxy builder.
|
ReverseProxyBuilder |
sendLegacyForwardedHeaders(boolean sendLegacyForwardedHeaders)
Murp always sends
Forwarded headers, however by default does not send the
non-standard X-Forwarded-* headers. |
ReverseProxyBuilder |
withHttpClient(org.eclipse.jetty.client.HttpClient httpClient)
Specifies the Jetty HTTP client to use to make the request to the target server.
|
ReverseProxyBuilder |
withTotalTimeout(long totalTimeoutInMillis)
Sets the total request timeout in millis for a proxied request.
|
ReverseProxyBuilder |
withTotalTimeout(long totalTimeout,
TimeUnit unit)
Sets the total request timeout in millis for a proxied request.
|
ReverseProxyBuilder |
withUriMapper(UriMapper uriMapper)
Required value.
|
ReverseProxyBuilder |
withViaName(String viaName)
The name to add as the
Via header, which defaults to private. |
public ReverseProxyBuilder withViaName(String viaName)
Via header, which defaults to private.viaName - The name to add to the Via header.public ReverseProxyBuilder withHttpClient(org.eclipse.jetty.client.HttpClient httpClient)
httpClient - The HTTP client to use, or null to use the default client.public ReverseProxyBuilder withUriMapper(UriMapper uriMapper)
If you want to proxy all requests to a single destination, consider using UriMapper.toDomain(URI)
If the mapper function returns null, then the handler will not proxy the request and the next handler in the chain will be invoked (or a 404 will be returned if there are no further handlers that can handle the request).
uriMapper - A mapper that creates a target URI based on a client request.public ReverseProxyBuilder sendLegacyForwardedHeaders(boolean sendLegacyForwardedHeaders)
Forwarded headers, however by default does not send the
non-standard X-Forwarded-* headers. Set this to true to enable
these legacy headers for older clients that rely on them.sendLegacyForwardedHeaders - true to forward headers such as X-Forwarded-Host; otherwise falsepublic ReverseProxyBuilder proxyHostHeader(boolean sendHostToTarget)
Specifies whether or not to send the original Host header to the target server.
Reverse proxies are generally supposed to forward the original Host header to target
servers, however there are cases (particularly where you are proxying to HTTPS servers) that the
Host needs to match the Host of the SSL certificate (in which case you may see SNI-related errors).
sendHostToTarget - If true (which is the default) the Host request
header will be sent to the target; if false then the host header
will be based on the target's URL.public ReverseProxyBuilder discardClientForwardedHeaders(boolean discardClientForwardedHeaders)
Forwarded or X-Forwarded-* headers that are sent
from the client to this reverse proxy will be dropped (defaults to false). Set this to true
if you do not trust the client.discardClientForwardedHeaders - true to ignore Forwarded headers from the client; otherwise falsepublic ReverseProxyBuilder withTotalTimeout(long totalTimeoutInMillis)
totalTimeoutInMillis - The allowed time in milliseconds for a request.public ReverseProxyBuilder withTotalTimeout(long totalTimeout, TimeUnit unit)
totalTimeout - The allowed time for a request.unit - The timeout unit.public ReverseProxyBuilder addProxyCompleteListener(ProxyCompleteListener proxyCompleteListener)
proxyCompleteListener - A listener to be called when a proxy request is completepublic static ReverseProxyBuilder reverseProxy()
public ReverseProxy build()
MuServerBuilder.addHandler(MuHandler)build in interface io.muserver.MuHandlerBuilder<ReverseProxy>Copyright © 2019. All rights reserved.