diff --git a/caddy/frankenphp/Caddyfile b/caddy/frankenphp/Caddyfile index e83dc3656..da58cdbff 100644 --- a/caddy/frankenphp/Caddyfile +++ b/caddy/frankenphp/Caddyfile @@ -5,7 +5,12 @@ #worker /path/to/your/worker.php {$FRANKENPHP_CONFIG} } + + # https://caddyserver.com/docs/caddyfile/directives#sorting-algorithm + order mercure after encode + order vulcain after reverse_proxy order php_server before file_server + order php before file_server } {$CADDY_EXTRA_CONFIG} diff --git a/docs/config.md b/docs/config.md index de757493a..324737126 100644 --- a/docs/config.md +++ b/docs/config.md @@ -25,17 +25,17 @@ Minimal example: ```caddyfile { - # Enable FrankenPHP - frankenphp - # Configure when the directive must be executed - order php_server before file_server + # Enable FrankenPHP + frankenphp + # Configure when the directive must be executed + order php_server before file_server } localhost { - # Enable compression (optional) - encode zstd gzip - # Execute PHP files in the current directory and serve assets - php_server + # Enable compression (optional) + encode zstd gzip + # Execute PHP files in the current directory and serve assets + php_server } ``` @@ -43,14 +43,14 @@ Optionally, the number of threads to create and [worker scripts](worker.md) to s ```caddyfile { - frankenphp { - num_threads # Sets the number of PHP threads to start. Default: 2x the number of available CPUs. - worker { - file # Sets the path to the worker script. - num # Sets the number of PHP threads to start, defaults to 2x the number of available CPUs. - env # Sets an extra environment variable to the given value. Can be specified more than once for multiple environment variables. - } - } + frankenphp { + num_threads # Sets the number of PHP threads to start. Default: 2x the number of available CPUs. + worker { + file # Sets the path to the worker script. + num # Sets the number of PHP threads to start, defaults to 2x the number of available CPUs. + env # Sets an extra environment variable to the given value. Can be specified more than once for multiple environment variables. + } + } } # ... @@ -60,31 +60,31 @@ Alternatively, the short form of the `worker` directive can also be used: ```caddyfile { - frankenphp { - worker - } + frankenphp { + worker + } } # ... ``` You can also define multiple workers if you serve multiple apps on the same server: - + ```caddyfile { - frankenphp { - worker /path/to/app/public/index.php - worker /path/to/other/public/index.php - } + frankenphp { + worker /path/to/app/public/index.php + worker /path/to/other/public/index.php + } } app.example.com { - root /path/to/app/public/ + root /path/to/app/public/ } other.example.com { - root /path/to/other/public/ + root /path/to/other/public/ } ... ``` @@ -97,14 +97,14 @@ Using the `php_server` directive is equivalent to this configuration: ```caddyfile # Add trailing slash for directory requests @canonicalPath { - file {path}/index.php - not path */ + file {path}/index.php + not path */ } redir @canonicalPath {path}/ 308 # If the requested file does not exist, try index files @indexFiles file { - try_files {path} {path}/index.php index.php - split_path .php + try_files {path} {path}/index.php index.php + split_path .php } rewrite @indexFiles {http.matchers.file.relative} # FrankenPHP! @@ -117,10 +117,10 @@ The `php_server` and the `php` directives have the following options: ```caddyfile php_server [] { - root # Sets the root folder to the site. Default: `root` directive. - split_path # Sets the substrings for splitting the URI into two parts. The first matching substring will be used to split the "path info" from the path. The first piece is suffixed with the matching substring and will be assumed as the actual resource (CGI script) name. The second piece will be set to PATH_INFO for the CGI script to use. Default: `.php` - resolve_root_symlink # Enables resolving the `root` directory to its actual value by evaluating a symbolic link, if one exists. - env # Sets an extra environment variable to the given value. Can be specified more than once for multiple environment variables. + root # Sets the root folder to the site. Default: `root` directive. + split_path # Sets the substrings for splitting the URI into two parts. The first matching substring will be used to split the "path info" from the path. The first piece is suffixed with the matching substring and will be assumed as the actual resource (CGI script) name. The second piece will be set to PATH_INFO for the CGI script to use. Default: `.php` + resolve_root_symlink # Enables resolving the `root` directory to its actual value by evaluating a symbolic link, if one exists. + env # Sets an extra environment variable to the given value. Can be specified more than once for multiple environment variables. } ```