This page is about Caddy 1 and will stay here forever.

User Guide

http.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] { root directory ext extension split splitval index indexfile env key value except ignored_paths... upstream endpoint connect_timeout duration read_timeout duration send_timeout duration }

For HTTPS connections, the following environment variables are set, in a manner compliant with httpd's mod_ssl: HTTPS, SSL_PROTOCOL, and SSL_CIPHER.

Presets

A preset is shorthand for a certain FastCGI configuration. These presets are available:

You do not need to specify the individual configuration settings for a preset. However, you can overwrite its individual settings if needed by declaring them manually.

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 }

With PHP preset, but the FastCGI server is running in a container based on an official Docker image (with container port 9000 published to 127.0.0.1:9001):

fastcgi / 127.0.0.1:9001 php { root /var/www/html }

Need help with this feature?

Join us in the Caddy forum, where the open source community gathers to share their knowledge.

Does your company use Caddy?

Purchase a commercial license to use Caddy with your business and for basic email support, along with other benefits!