diff --git a/v2:-Documentation.md b/v2:-Documentation.md index a4f3d0d..3889f8d 100644 --- a/v2:-Documentation.md +++ b/v2:-Documentation.md @@ -37,6 +37,7 @@ Features which are available in Caddy Enterprise are indicated with   🏢 - [file_server](#file_server) - [encode](#encode) - [headers](#headers) + - [php_fastcgi](#php_fastcgi) - [reverse_proxy](#reverse_proxy) - [redir](#redir) - [rewrite](#rewrite) @@ -520,6 +521,37 @@ headers [] [[+|-] ] { } ``` +##### php_fastcgi + +Proxies requests to one or more FastCGI backends specially configured for PHP apps. It has the same syntax and options as [reverse_proxy](#reverse_proxy), but is shorthand for a configuration equivalent to this example: + +``` +# internally rewrite URIs to match index.php files +matcher indexFiles { + file { + try_files {path} index.php + } +} +rewrite match:indexFiles {http.matchers.file.relative} + +# proxy any requests for PHP files to backend via FastCGI +matcher phpFiles { + path *.php +} +reverse_proxy match:phpFiles php-fpm:9000 { + transport fastcgi { + split .php + } +} +``` + +Thus, the following single line is sufficient and works for _most_ PHP scripts (replace php-fpm:9000 with your php-fpm listener): + +``` +php_fastcgi php-fpm:9000 +``` + + ##### reverse_proxy Proxies requests to one or more backends with configurable transport options. @@ -580,6 +612,8 @@ transport fastcgi { } ``` +For proxying to PHP via FastCGI (php-fpm) specifically, see the [php_fastcgi](#php_fastcgi) directive. + ##### redir Issue an HTTP redirect.