Minor touch-ups

This commit is contained in:
Matthew Holt 2020-05-17 16:58:59 -06:00
parent e287e61df6
commit 257bec43d5
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
3 changed files with 11 additions and 7 deletions

View file

@ -4,7 +4,9 @@ title: file_server (Caddyfile directive)
# file_server # file_server
A static file server. It works by appending the request's URI path to the [site's root path](/docs/caddyfile/directives/root). A static file server. It works by appending the request's URI path to the [site's root path](/docs/caddyfile/directives/root). By default, it enforces canonical URIs; if necessary, requests to directories will be redirected to have a trailing forward slash, and requests to files will be redirected to strip the trailing slash.
Most often, the `file_server` directive is paired with the [`root`](/docs/caddyfile/directives/root) directive to set file root for the whole site.
## Syntax ## Syntax
@ -19,7 +21,7 @@ file_server [<matcher>] [browse] {
``` ```
- **browse** enables file listings for requests to directories that do not have an index file. - **browse** enables file listings for requests to directories that do not have an index file.
- **root** sets the path to the site root for just this file server instance, overriding any other. Default: `{http.vars.root}` or the current working directory. Note: When specified as a subdirective like this, only this directive will know this root; for other directives (like [`try_files`](/docs/caddyfile/directives/try_files) or [`templates`](/docs/caddyfile/directives/templates)) to know the same site root, use the [`root`](/docs/caddyfile/directives/root) directive, not subdirective. - **root** sets the path to the site root for just this file server instance, overriding any other. Default: `{http.vars.root}` or the current working directory. Note: This subdirective only changes the root for this directive. For other directives (like [`try_files`](/docs/caddyfile/directives/try_files) or [`templates`](/docs/caddyfile/directives/templates)) to know the same site root, use the [`root`](/docs/caddyfile/directives/root) directive, not this subdirective.
- **hide** is a list of files to hide; if requested, the file server will pretend they do not exist. The active configuration file will be added by default. - **hide** is a list of files to hide; if requested, the file server will pretend they do not exist. The active configuration file will be added by default.
- **index** is a list of filenames to look for as index files. Default: `index.html index.txt` - **index** is a list of filenames to look for as index files. Default: `index.html index.txt`
- **<template_file>** is an optional custom template file to use for directory listings. - **<template_file>** is an optional custom template file to use for directory listings.
@ -45,9 +47,9 @@ Only serve static files out of the `/static` folder:
file_server /static/* file_server /static/*
``` ```
The `file_server` directive is usually paired with the [`root`](/docs/caddyfile/directives/root) directive to set the root path from which to serve files The `file_server` directive is usually paired with the [`root` directive](/docs/caddyfile/directives/root) to set the root path from which to serve files:
```caddy-d ```caddy-d
root * /home/user/public_html root * /home/user/public_html
file_server file_server
``` ```

View file

@ -80,7 +80,7 @@ When using php-fpm listening via a unix socket:
php_fastcgi unix//run/php/php7.4-fpm.sock php_fastcgi unix//run/php/php7.4-fpm.sock
``` ```
The `php_fastcgi` directive is usually paired with the [`root`](/docs/caddyfile/directives/root) directive to set the root path from which to serve PHP files The [`root` directive](/docs/caddyfile/directives/root) is often used to specify the directory containing the PHP files:
```caddy-d ```caddy-d
root * /var/www/html root * /var/www/html

View file

@ -8,6 +8,8 @@ Sets the root path of the site, used by various matchers and directives that acc
Specifically, this directive sets the `{http.vars.root}` placeholder. It is mutually exclusive to other `root` directives in the same block, so it is safe to define multiple roots with matchers that intersect: they will not cascade and overwrite each other. Specifically, this directive sets the `{http.vars.root}` placeholder. It is mutually exclusive to other `root` directives in the same block, so it is safe to define multiple roots with matchers that intersect: they will not cascade and overwrite each other.
This directive does not automatically enable serving static files, so it is often used in conjunction with the [`file_server` directive](/docs/caddyfile/directives/file_server) or the [`php_fastcgi` directive](/docs/caddyfile/directives/php_fastcgi).
## Syntax ## Syntax
@ -17,7 +19,7 @@ root [<matcher>] <path>
- **&lt;path&gt;** is the path to use for the site root. - **&lt;path&gt;** is the path to use for the site root.
Note that a matcher token is usually required since the first argument is a path, which could look like a path matcher. Note that the `<path>` argument could be confused by the parser as a [matcher token](/docs/caddyfile/matchers#syntax) if the it begins with `/`. To disambiguate, specify a wildcard matcher token (`*`). See examples below.
## Examples ## Examples
@ -37,7 +39,7 @@ Set the site root to `public_html` (relative to current working directory) for a
root public_html root public_html
``` ```
Set the site root only for requests in `/foo`: Change the site root only for requests in `/foo/*`:
```caddy-d ```caddy-d
root /foo/* /home/user/public_html/foo root /foo/* /home/user/public_html/foo