This module requires the service of
Thus, in order to get the ability of handling the FastCGI
protocol,
Unlike mod_fcgid
and mod_fastcgi,
Do not enable proxying until you have secured your server. Open proxy servers are dangerous both to your network and to the Internet at large.
Remember, in order to make the following examples work, you have to
enable
Please keep in mind that PHP-FPM (at the time of writing, February 2018)
uses a prefork model, namely each of its worker processes can handle one
connection at the time.
By default mod_proxy (configured with enablereuse=on
)
allows a connection pool of
The maximum number of PHP-FPM worker processes needs to be configured wisely, since there is the chance that they will all end up "busy" handling idle persistent connections, without any room for new ones to be established, and the end user experience will be a pile of HTTP request timeouts.
The following example passes the request URI as a filesystem path for the PHP-FPM daemon to run. The request URL is implicitly added to the 2nd parameter. The hostname and port following fcgi:// are where PHP-FPM is listening. Connection pooling/reuse is enabled.
The following example passes the request URI as a filesystem path for the PHP-FPM daemon to run. In this case, PHP-FPM is listening on a unix domain socket (UDS). Requires 2.4.9 or later. With this syntax, the hostname and optional port following fcgi:// are ignored.
The following example forces the module to flush every chunk of data received from the FCGI backend as soon as it receives it, without buffering.
The following example is related to the previous one with a difference: the module waits/polls for a fixed amount of time before flushing (buffering data from the FCGI backend). This method is useful when the FCGI backend emits data in short bursts, since forcing a flush would result inefficient and expensive for performances. Please note that this setting might not be the best one in use cases when outgoing data chunks from the FCGI application are blocked waiting on incoming chunks from the client.
The balanced gateway needs
You can also force a request to be handled as a reverse-proxy request, by creating a suitable Handler pass-through. The example configuration below will pass all requests for PHP scripts to the specified FastCGI server using reverse proxy. This feature is available in Apache HTTP Server 2.4.10 and later. For performance reasons, you will want to define a worker representing the same fcgi:// backend. The benefit of this form is that it allows the normal mapping of URI to filename to occur in the server, and the local filesystem result is passed to the backend. When FastCGI is configured this way, the server can calculate the most accurate PATH_INFO.
In addition to the configuration directives that control the
behaviour of
This directive allows the type of backend FastCGI application to be specified. Some FastCGI servers, such as PHP-FPM, use historical quirks of environment variables to identify the type of proxy server being used. Set this directive to "GENERIC" if your non PHP-FPM application has trouble interpreting environment variables such as SCRIPT_FILENAME or PATH_TRANSLATED as set by the server.
One example of values that change based on the setting of this directive is
SCRIPT_FILENAME. When using
Just before passing a request to the configured FastCGI server, the core of the web server sets a number of environment variables based on details of the current request. FastCGI programs often uses these environment variables as inputs that determine what underlying scripts they will process, or what output they directly produce.
Examples of noteworthy environment variables are:
This directive allows the environment variables above, or any others of interest, to be overridden. This directive is evaluated after the initial values for these variables are set, so they can be used as input into both the condition expressions and value expressions.
Parameter syntax:
VARIABLE
, preventing it from being sent
to the FastCGI server:
VARIABLE
(by setting it to the empty string), but the empty
VARIABLE
will still be sent to the server: