docs: Minor updates to file_server and reverse_proxy

This commit is contained in:
Matthew Holt 2021-06-17 14:12:48 -06:00
parent 639c76b54c
commit 85dbc186c2
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
4 changed files with 11 additions and 10 deletions

View file

@ -4,7 +4,9 @@ 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). 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.
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; 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).
Most often, the `file_server` directive is paired with the [`root`](/docs/caddyfile/directives/root) directive to set file root for the whole site.
@ -26,8 +28,7 @@ file_server [<matcher>] [browse] {
- **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`
- **<template_file>** is an optional custom template file to use for directory listings. Defaults to the template that can be found [here in the source code ![external link](/resources/images/external-link.svg)](https://github.com/caddyserver/caddy/blob/master/modules/caddyhttp/fileserver/browsetpl.go). Browse templates can use actions from [the standard templates module](/docs/modules/http.handlers.templates#docs) as well.
- **precompressed** is the list of encoding formats to search for precompressed sidecar files.
- **&lt;formats...&gt;** is the ordered list of encoding formats to search for precompressed sidecar files. Supported formats are `gzip`, `zstd` and `br`.
- **precompressed** is the list of encoding formats to search for precompressed sidecar files. Arguments are an ordered list of encoding formats to search for precompressed sidecar files. Supported formats are `gzip`, `zstd` and `br`.
- **status** is an optional status code override to be used when writing the response. Particularly useful when responding to a request with a custom error page. Can be a 3-digit status code, For example: `404`. Placeholders are supported. By default, the written status code will typically be `200`, or `206` for partial content.
## Examples

View file

@ -204,10 +204,10 @@ transport http {
tls_server_name <sni>
keepalive [off|<duration>]
keepalive_idle_conns <max_count>
keepalive_idle_conns_per_host <count>
versions <versions...>
compression off
max_conns_per_host <count>
max_idle_conns_per_host <count>
}
```
@ -226,10 +226,10 @@ transport http {
- **tls_server_name** sets the ServerName (SNI) to put in the ClientHello; only needed if the remote server requires it.
- **keepalive** is either `off` or a [duration value](/docs/conventions#durations) that specifies how long to keep connections open.
- **keepalive_idle_conns** defines the maximum number of connections to keep alive.
- **keepalive_idle_conns_per_host** if non-zero, controls the maximum idle (keep-alive) connections to keep per-host. Default: `32`
- **versions** allows customizing which versions of HTTP to support. As a special case, "h2c" is a valid value which will enable cleartext HTTP/2 connections to the upstream (however, this is a non-standard feature that does not use Go's default HTTP transport, so it is exclusive of other features; subject to change or removal). Default: `1.1 2`, or if scheme is `h2c://`, `h2c 2`
- **compression** can be used to disable compression to the backend by setting it to `off`.
- **max_conns_per_host** optionally limits the total number of connections per host, including connections in the dialing, active, and idle states. Has no limit by default.
- **max_idle_conns_per_host** if non-zero, controls the maximum idle (keepalive) connections to keep per-host. Default: `2`

View file

@ -45,7 +45,7 @@ The ellipses `...` indicates a continuation, i.e. one or more parameters.
Changes the config of the running Caddy process
- **[caddy reverse-proxy](#caddy-reverse-proxy)**
A simple but production-ready reverse proxy
A simple but production-ready HTTP(S) reverse proxy
- **[caddy run](#caddy-run)**
Starts the Caddy process in the foreground
@ -246,7 +246,7 @@ Because this command uses the API, the admin endpoint must not be disabled.
--to &lt;addr&gt;
[--change-host-header]</code></pre>
Spins up a simple but production-ready reverse proxy.
Spins up a simple but production-ready HTTP(S) reverse proxy.
`--from` is the address to proxy from.