mirror of
https://github.com/caddyserver/website.git
synced 2025-04-21 20:46:15 -04:00
file_server: Add docs for virtual file system support.
This commit is contained in:
parent
cd102116b1
commit
cddded78a7
1 changed files with 3 additions and 1 deletions
|
@ -4,7 +4,7 @@ title: file_server (Caddyfile directive)
|
|||
|
||||
# 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 that supports real and virtual file systems. It forms file paths by appending the request's URI path to the [site's root path](/docs/caddyfile/directives/root).
|
||||
|
||||
By default, it enforces canonical URIs; meaning HTTP redirects will be issued for requests to directories that do not end with a trailing slash (to add it) or requests to files that have a trailing slash (to remove it). Redirects are not issued, however, if an internal rewrite modifies the last element of the path (the filename).
|
||||
|
||||
|
@ -14,6 +14,7 @@ Most often, the `file_server` directive is paired with the [`root`](/docs/caddyf
|
|||
|
||||
```caddy-d
|
||||
file_server [<matcher>] [browse] {
|
||||
fs <backend...>
|
||||
root <path>
|
||||
hide <files...>
|
||||
index <filenames...>
|
||||
|
@ -26,6 +27,7 @@ file_server [<matcher>] [browse] {
|
|||
```
|
||||
|
||||
- **browse** enables file listings for requests to directories that do not have an index file.
|
||||
- **fs** specifies an alternate (perhaps virtual) file system to use. Any Caddy module in the `caddy.fs` namespace can be used here as long as it supports [`Stat()` calls](https://pkg.go.dev/io/fs#StatFS). Any root path/prefix will still apply to alternate file system modules. By default, the local disk is used.
|
||||
- **root** sets the path to the site root. It's similar to the [`root`](/docs/caddyfile/directives/root) directive except it applies to this file server instance only and overrides any other site root that may have been defined. 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 or folders to hide; if requested, the file server will pretend they do not exist. Accepts placeholders and glob patterns. Note that these are _file system_ paths, NOT request paths. In other words, relative paths use the current working directory as a base, NOT the site root; and all paths are transformed to their absolute form before comparisons (if possible). Specifying a file name or pattern without a path separator will hide all files with a matching name regardless of its location; otherwise, a path prefix match will be attempted, and then a globular match. Since this is a Caddyfile config, the active configuration file(s) will be added by default.
|
||||
- **index** is a list of filenames to look for as index files. Default: `index.html index.txt`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue