Configure FastCGI for Apache 2.4
For Apache 2.4, you configure FastCGI with the mod_proxy_fcgi module. If authorization is used, configure a rewrite rule.
Follow this procedure to configure Apache to use the mod_proxy_fcgi
module to
connect to a GAS server. The GAS may be on a local or a remote machine.
If you are using authorization headers, see the configuration example in the section Rewrite-rule for authorization headers.
Apache 2.4 does not officially support the mod_fastcgi
module; use the
mod_proxy_fcgi
module instead. This module requires GAS 2.50 or later.
For more information on Apache modules, refer to the Apache documentation.
Rewrite-rule for authorization headers
If you are using authorization headers, the module mod_rewrite
must be enabled
in your Apache configuration file. For example, the load module directive for this module must
appear without the hash (#) at the start of the line:
LoadModule rewrite_module modules/mod_rewrite.so
- Authorization headers need to be base64 encoded. Apache discards the Authorization header if it is not a base64-encoded user/password combination. A rewrite rule (see Apache 2.4 documentation) can be used to rewrite it from the server variable.
- A
ProxyPassReverse
directive can be set to adjust or rewrite URLs in response headers before forwarding them on to the client. For example, if an authorization request causes a redirect to an authentication server, Apache adjusts this URL to the local URL before forwarding the HTTP redirect response to the client.For more details on Apache, see Apache 2.4 documentation.
An example configuration is shown:
...
<VirtualHost _default_>
<IfModule proxy_fcgi_module>
...
# Unescapes the path component of the request URL
SetEnvIf Request_URI . proxy-fcgi-pathinfo=unescape
# Recreates the authorization header from the %{HTTP:Authorization} variable
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Maps the fastcgi server to the GAS URL space
ProxyPass /gas/ fcgi://gas-server-ip:gas-server-port/gas/ enablereuse=on timeout=100
# Rewrites URL in response headers
ProxyPassReverse /gas/ http://gas-server-ip:gas-server-port/gas/
# No alias
</IfModule>
</VirtualHost>
...