Class FastCGIProxyHandler

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.server.Handler.Abstract
org.eclipse.jetty.proxy.ProxyHandler
org.eclipse.jetty.proxy.ProxyHandler.Reverse
org.eclipse.jetty.fcgi.proxy.FastCGIProxyHandler
All Implemented Interfaces:
org.eclipse.jetty.server.Handler, org.eclipse.jetty.server.Request.Handler, org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.LifeCycle, org.eclipse.jetty.util.thread.Invocable

public class FastCGIProxyHandler extends org.eclipse.jetty.proxy.ProxyHandler.Reverse

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:
  • TryPathsHandler
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.eclipse.jetty.proxy.ProxyHandler

    org.eclipse.jetty.proxy.ProxyHandler.Forward, org.eclipse.jetty.proxy.ProxyHandler.ProxyRequestContent, org.eclipse.jetty.proxy.ProxyHandler.ProxyResponseListener, org.eclipse.jetty.proxy.ProxyHandler.Reverse

    Nested classes/interfaces inherited from class org.eclipse.jetty.server.Handler.Abstract

    org.eclipse.jetty.server.Handler.Abstract.NonBlocking

    Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopException

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container

    org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable

    org.eclipse.jetty.util.component.Dumpable.DumpableContainer

    Nested classes/interfaces inherited from interface org.eclipse.jetty.server.Handler

    org.eclipse.jetty.server.Handler.Abstract, org.eclipse.jetty.server.Handler.AbstractContainer, org.eclipse.jetty.server.Handler.Collection, org.eclipse.jetty.server.Handler.Container, org.eclipse.jetty.server.Handler.Sequence, org.eclipse.jetty.server.Handler.Singleton, org.eclipse.jetty.server.Handler.Wrapper

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable

    org.eclipse.jetty.util.thread.Invocable.Callable, org.eclipse.jetty.util.thread.Invocable.InvocationType, org.eclipse.jetty.util.thread.Invocable.ReadyTask, org.eclipse.jetty.util.thread.Invocable.Task

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

    org.eclipse.jetty.util.component.LifeCycle.Listener
  • 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.component.Dumpable

    KEY

    Fields inherited from interface org.eclipse.jetty.util.thread.Invocable

    __nonBlocking, NOOP
  • Constructor Summary

    Constructors
    Constructor
    Description
    FastCGIProxyHandler(String uriPattern, String uriReplacement, String scriptRoot)
    Creates a new instance that rewrites the HttpURI with the given pattern and replacement strings, using String.replaceAll(String, String).
    FastCGIProxyHandler(Function<org.eclipse.jetty.server.Request,org.eclipse.jetty.http.HttpURI> httpURIRewriter, String scriptRoot)
    Creates a new instance with the given HttpURI rewriter function.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    customizeFastCGIHeaders(org.eclipse.jetty.client.Request proxyToServerRequest, org.eclipse.jetty.http.HttpFields.Mutable fastCGIHeaders)
     
    protected void
     
     
     
     
     
    Get the root directory path of the FastCGI files.
     
    boolean
     
    protected org.eclipse.jetty.client.HttpClient
     
    protected void
    sendProxyToServerRequest(org.eclipse.jetty.server.Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest, org.eclipse.jetty.server.Response proxyToClientResponse, org.eclipse.jetty.util.Callback proxyToClientCallback)
     
    void
    setFastCGIEnvNames(Set<String> fcgiEnvNames)
    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.
    void
    setFastCGISecure(boolean fcgiSecure)
    Sets whether to forward the HTTPS 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, 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

    dumpSelf

    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

      public FastCGIProxyHandler(String uriPattern, String uriReplacement, String scriptRoot)

      Creates a new instance that rewrites the HttpURI with the given pattern and replacement strings, using String.replaceAll(String, String).

      Parameters:
      uriPattern - the regex pattern to use to match the incoming URI
      uriReplacement - the replacement string to use to rewrite the incoming URI
      scriptRoot - the root directory path of the FastCGI files
      See Also:
      • Reverse(String, String)
    • FastCGIProxyHandler

      public FastCGIProxyHandler(Function<org.eclipse.jetty.server.Request,org.eclipse.jetty.http.HttpURI> httpURIRewriter, String scriptRoot)

      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 FastCGI DOCUMENT_ROOT parameter.

      Parameters:
      httpURIRewriter - a function that returns the URI of the FastCGI server
      scriptRoot - the root directory path of the FastCGI files
  • Method Details

    • getScriptRoot

      public String getScriptRoot()
      Get the root directory path of the FastCGI files.
      Returns:
      the root directory path of the FastCGI files
    • getScriptPattern

      public Pattern getScriptPattern()
      Returns:
      the regular expression that extracts the SCRIPT_NAME and the PATH_INFO FastCGI parameters
    • setScriptPattern

      public void setScriptPattern(Pattern scriptPattern)

      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 the SCRIPT_NAME and the PATH_INFO FastCGI parameters
    • getOriginalPathAttribute

      public String getOriginalPathAttribute()
      Returns:
      the attribute name of the original client-to-proxy request path
    • setOriginalPathAttribute

      public void setOriginalPathAttribute(String originalPathAttribute)

      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

      public String getOriginalQueryAttribute()
      Returns:
      the attribute name of the original client-to-proxy request query
    • setOriginalQueryAttribute

      public void setOriginalQueryAttribute(String originalQueryAttribute)

      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 the HTTPS FastCGI parameter in the FastCGI request
    • getFastCGIEnvNames

      public Set<String> getFastCGIEnvNames()
      Returns:
      the names of the environment variables forwarded in the FastCGI request
    • setFastCGIEnvNames

      public void setFastCGIEnvNames(Set<String> fcgiEnvNames)

      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

      public Path getUnixDomainPath()
      Returns:
      the Unix-Domain path the FastCGI server listens to, or null if the FastCGI server listens over network
    • setUnixDomainPath

      public void setUnixDomainPath(Path unixDomainPath)

      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

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.eclipse.jetty.proxy.ProxyHandler
      Throws:
      Exception
    • newHttpClient

      protected org.eclipse.jetty.client.HttpClient newHttpClient()
      Overrides:
      newHttpClient in class org.eclipse.jetty.proxy.ProxyHandler
    • sendProxyToServerRequest

      protected void sendProxyToServerRequest(org.eclipse.jetty.server.Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest, org.eclipse.jetty.server.Response proxyToClientResponse, org.eclipse.jetty.util.Callback proxyToClientCallback)
      Overrides:
      sendProxyToServerRequest in class org.eclipse.jetty.proxy.ProxyHandler
    • customizeFastCGIHeaders

      protected void customizeFastCGIHeaders(org.eclipse.jetty.client.Request proxyToServerRequest, org.eclipse.jetty.http.HttpFields.Mutable fastCGIHeaders)