fastcgi
fastcgi proxies requests to a FastCGI server. Even though the most common use for this directive is to serve PHP sites, it is by default a generic FastCGI proxy. This directive may be used multiple times with different request paths.
Syntax
fastcgi path endpoint [preset] {
ext extension
split splitval
index indexfile
env key value
}
- path is the base path to match before the request will be forwarded
- endpoint is the address or Unix socket of the FastCGI server
- preset is an optional preset name (see below)
- extension specifies the extension which, if the request URL has it, would proxy the request to FastCGI
- splitval specifies how to split the URL; the split value becomes the end of the first part and anything in the URL after it becomes part of the PATH_INFO CGI variable
- indexfile specifies the default file to try if a file is not specified by the URL
- key value sets an environment variable named key with the given value; the env property can be used multiple times
Presets
This directive can be customized to work with a variety of FastCGI applications. To make things easier for proxying to common types of sites, some presets have been configured:
-
php
ext .php split .php index index.php
If a preset is used, its values can be overwritten if needed by declaring them manually inside the block.
Examples
Proxy all requests to a FastCGI responder listening at 127.0.0.1:9000:
fastcgi / 127.0.0.1:9000
Forward all requests in /blog to a PHP site (like WordPress) being served with php-fpm:
fastcgi /blog 127.0.0.1:9000 php
With custom FastCGI configuration:
fastcgi / 127.0.0.1:9001 {
split .html
}
With PHP preset, but overriding the ext property:
fastcgi / 127.0.0.1:9001 php {
ext .html
}

