Class FastCGIProxyHandler
- All Implemented Interfaces:
Handler
,Request.Handler
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
,Invocable
Specific implementation of ProxyHandler.Reverse
for FastCGI.
This handler accepts an HTTP request and transforms it into a FastCGI request that is sent to the FastCGI server, and viceversa for the response.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.proxy.ProxyHandler
ProxyHandler.Forward, ProxyHandler.ProxyRequestContent, ProxyHandler.ProxyResponseListener, ProxyHandler.Reverse
Nested classes/interfaces inherited from class org.eclipse.jetty.server.Handler.Abstract
Handler.Abstract.NonBlocking
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopException
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
Nested classes/interfaces inherited from interface org.eclipse.jetty.server.Handler
Handler.Abstract, Handler.AbstractContainer, Handler.Collection, Handler.Container, Handler.Sequence, Handler.Singleton, Handler.Wrapper
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.Task
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.server.Request.Handler
Request.Handler.AbortException
-
Field Summary
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, STARTED, STARTING, STOPPED, STOPPING
Fields inherited from interface org.eclipse.jetty.util.thread.Invocable
__nonBlocking, NOOP
-
Constructor Summary
ConstructorDescriptionFastCGIProxyHandler
(String uriPattern, String uriReplacement, String scriptRoot) Creates a new instance that rewrites theHttpURI
with the given pattern and replacement strings, usingString.replaceAll(String, String)
.FastCGIProxyHandler
(Function<Request, HttpURI> httpURIRewriter, String scriptRoot) Creates a new instance with the givenHttpURI
rewriter function. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
customizeFastCGIHeaders
(Request proxyToServerRequest, HttpFields.Mutable fastCGIHeaders) protected void
doStart()
Starts the managed lifecycle beans in the order they were added.Get the root directory path of the FastCGI files.boolean
protected HttpClient
Creates a newHttpClient
instance, by default with a thread pool namedproxy-client
and with thedynamic transport
configured only with HTTP/1.1.protected void
sendProxyToServerRequest
(Request clientToProxyRequest, Request proxyToServerRequest, Response proxyToClientResponse, Callback proxyToClientCallback) void
setFastCGIEnvNames
(Set<String> fcgiEnvNames) Sets the names of environment variables that will forwarded, along with their value retrieved viaSystem.getenv(String)
, in the FastCGI request to the FastCGI server.void
setFastCGISecure
(boolean fcgiSecure) Sets whether to forward theHTTPS
FastCGI parameter in the FastCGI request to the FastCGI server.void
setOriginalPathAttribute
(String originalPathAttribute) Sets the client-to-proxy request attribute name to use to retrieve the original request path.void
setOriginalQueryAttribute
(String originalQueryAttribute) Sets the client-to-proxy request attribute name to use to retrieve the original request query.void
setScriptPattern
(Pattern scriptPattern) Sets a regular expression with at least 1 and at most 2 groups that specify respectively:void
setUnixDomainPath
(Path unixDomainPath) Sets the Unix-Domain path the FastCGI server listens to.Methods inherited from class org.eclipse.jetty.proxy.ProxyHandler.Reverse
getHttpURIRewriter, rewriteHttpURI
Methods inherited from class org.eclipse.jetty.proxy.ProxyHandler
addForwardedHeader, addProxyHeaders, addViaHeader, configureHttpClient, copyRequestHeaders, filterServerToProxyResponseField, getHttpClient, getProxyToServerHost, getViaHost, handle, newProxyToServerRequest, newProxyToServerRequestContent, newServerToProxyResponseListener, onProxyToClientResponseComplete, onProxyToClientResponseFailure, onServerToProxyResponse100Continue, onServerToProxyResponse102Processing, onServerToProxyResponse103EarlyHints, onServerToProxyResponseFailure, requestId, setHttpClient, setProxyToServerHost, setViaHost
Methods inherited from class org.eclipse.jetty.server.Handler.Abstract
destroy, doStop, getInvocationType, getServer, setServer
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.util.component.Container
getCachedBeans, getEventListeners
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addEventListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, start, stop
-
Constructor Details
-
FastCGIProxyHandler
Creates a new instance that rewrites the
HttpURI
with the given pattern and replacement strings, usingString.replaceAll(String, String)
.- Parameters:
uriPattern
- the regex pattern to use to match the incoming URIuriReplacement
- the replacement string to use to rewrite the incoming URIscriptRoot
- the root directory path of the FastCGI files- See Also:
-
FastCGIProxyHandler
Creates a new instance with the given
HttpURI
rewriter function.The
HttpURI
rewriter function should return the URI of the FastCGI server.The
scriptRoot
path must be set to the directory where the application that must be served via FastCGI is installed and corresponds to the FastCGIDOCUMENT_ROOT
parameter.- Parameters:
httpURIRewriter
- a function that returns the URI of the FastCGI serverscriptRoot
- the root directory path of the FastCGI files
-
-
Method Details
-
getScriptRoot
Get the root directory path of the FastCGI files.- Returns:
- the root directory path of the FastCGI files
-
getScriptPattern
- Returns:
- the regular expression that extracts the
SCRIPT_NAME
and thePATH_INFO
FastCGI parameters
-
setScriptPattern
Sets a regular expression with at least 1 and at most 2 groups that specify respectively:
- the FastCGI
SCRIPT_NAME
parameter - the FastCGI
PATH_INFO
parameter
- Parameters:
scriptPattern
- the regular expression that extracts theSCRIPT_NAME
and thePATH_INFO
FastCGI parameters
- the FastCGI
-
getOriginalPathAttribute
- Returns:
- the attribute name of the original client-to-proxy request path
-
setOriginalPathAttribute
Sets the client-to-proxy request attribute name to use to retrieve the original request path.
For example, the request URI may be rewritten by a previous handler that might save the original request path in a request attribute.
- Parameters:
originalPathAttribute
- the attribute name of the original client-to-proxy request path
-
getOriginalQueryAttribute
- Returns:
- the attribute name of the original client-to-proxy request query
-
setOriginalQueryAttribute
Sets the client-to-proxy request attribute name to use to retrieve the original request query.
For example, the request URI may be rewritten by a previous handler that might save the original request query in a request attribute.
- Parameters:
originalQueryAttribute
- the attribute name of the original client-to-proxy request query
-
isFastCGISecure
public boolean isFastCGISecure()- Returns:
- whether to forward the
HTTPS
FastCGI parameter in the FastCGI request
-
setFastCGISecure
public void setFastCGISecure(boolean fcgiSecure) Sets whether to forward the
HTTPS
FastCGI parameter in the FastCGI request to the FastCGI server.- Parameters:
fcgiSecure
- whether to forward theHTTPS
FastCGI parameter in the FastCGI request
-
getFastCGIEnvNames
- Returns:
- the names of the environment variables forwarded in the FastCGI request
-
setFastCGIEnvNames
Sets the names of environment variables that will forwarded, along with their value retrieved via
System.getenv(String)
, in the FastCGI request to the FastCGI server.- Parameters:
fcgiEnvNames
- the names of the environment variables forwarded in the FastCGI request- See Also:
-
getUnixDomainPath
- Returns:
- the Unix-Domain path the FastCGI server listens to,
or
null
if the FastCGI server listens over network
-
setUnixDomainPath
Sets the Unix-Domain path the FastCGI server listens to.
If the FastCGI server listens over the network (not over a Unix-Domain path), then the FastCGI server host and port must be specified by the
HttpURI
rewrite function passed to the constructor.- Parameters:
unixDomainPath
- the Unix-Domain path the FastCGI server listens to
-
doStart
Description copied from class:ContainerLifeCycle
Starts the managed lifecycle beans in the order they were added.- Overrides:
doStart
in classProxyHandler
- Throws:
AbstractLifeCycle.StopException
- If thrown, the lifecycle will immediately be stopped.Exception
- If there was a problem starting. Will cause a transition to FAILED state
-
newHttpClient
Description copied from class:ProxyHandler
Creates a new
HttpClient
instance, by default with a thread pool namedproxy-client
and with thedynamic transport
configured only with HTTP/1.1.- Overrides:
newHttpClient
in classProxyHandler
- Returns:
- a new
HttpClient
instance
-
sendProxyToServerRequest
protected void sendProxyToServerRequest(Request clientToProxyRequest, Request proxyToServerRequest, Response proxyToClientResponse, Callback proxyToClientCallback) - Overrides:
sendProxyToServerRequest
in classProxyHandler
-
customizeFastCGIHeaders
protected void customizeFastCGIHeaders(Request proxyToServerRequest, HttpFields.Mutable fastCGIHeaders)
-