docs: A few updates

This commit is contained in:
Matthew Holt 2020-04-27 18:19:08 -06:00
parent 7c550dc224
commit 1837e55742
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
4 changed files with 27 additions and 7 deletions

View file

@ -159,9 +159,10 @@ expression {method}.startsWith("P")
```
file {
root <paths>
try_files <files...>
root <paths>
try_files <files...>
try_policy first_exist|smallest_size|largest_size|most_recent_modified
split_path <delims...>
}
```
@ -174,6 +175,7 @@ By files.
- `smallest_size` chooses the file with the smallest size.
- `largest_size` chooses the file with the largest size.
- `most_recent_modified` chooses the file that was most recently modified.
- `split_path` will cause the path to be split at the first delimiter in the list that is found in each filepath to try. For each split value, the left-hand side of the split including the delimiter itself will be the filepath that is tried. For example, `/remote.php/dav/` using a delimiter of `.php` would try the file `/remote.php`. Each delimiter must appear at the end of a URI path component in order to be used as a split delimiter. This is a niche setting and is mostly used when serving PHP sites.
An empty `file` matcher will see if the requested file (verbatim from the URI, relative to the [site root](/docs/caddyfile/directives/root)) exists.

View file

@ -228,9 +228,9 @@ Because this command uses the API, the admin endpoint must not be disabled.
### `caddy reverse-proxy`
<pre><code class="cmd bash">caddy reverse-proxy
--from &lt;addr&gt;
[--from &lt;addr&gt;]
--to &lt;addr&gt;
--change-host-header</code></pre>
[--change-host-header]</code></pre>
Spins up a simple but production-ready reverse proxy.
@ -240,9 +240,9 @@ Spins up a simple but production-ready reverse proxy.
`--change-host-header` will cause Caddy to change the Host header from the incoming value to the address of the upstream.
Both `--from` and `--to` parameters can be URLs, as scheme, domain name, and URI rewrite information will be inferred from the provided URL (paths and query strings ignored). Or they can be a simple network address and not a complete URL.
Both `--from` and `--to` parameters can be URLs, as scheme and domain name will be inferred from the provided URL (paths and query strings ignored). Or they can be a simple network address and not a complete URL.
This command disables the admin API, making it easier to run multiple instances on a local development machine.
This command disables the admin API so it is easier to run multiple instances on a local development machine.
### `caddy run`

View file

@ -18,6 +18,7 @@ The following config adapters are currently available (some are third-party proj
- [**json5**](https://github.com/caddyserver/json5-adapter)
- [**yaml**](https://github.com/iamd3vil/caddy_yaml_adapter)
- [**cue**](https://github.com/caddyserver/cue-adapter)
- [**toml**](https://github.com/awoodbeck/caddy-toml-adapter)
(This list is the temporary home for known adapters until our new website is finished.)

View file

@ -18,6 +18,7 @@ This guide won't delve into the new features available -- which are really cool,
- [Command line](#command-line)
- [Caddyfile](#caddyfile)
- [Primary changes](#primary-changes)
- [basicauth](#basicauth)
- [browse](#browse)
- [ext](#ext)
- [fastcgi](#fastcgi)
@ -100,7 +101,6 @@ The [v2 Caddyfile](/docs/caddyfile/concepts) is very similar to what you're alre
### Primary changes
- If you are serving static files, you will need to add a [`file_server` directive](/docs/caddyfile/directives/file_server), since Caddy 2 does not assume this by default. Caddy 2 does not sniff MIME by default, either, for security reasons; if a Content-Type is missing you may need to set the header yourself using the [header](/docs/caddyfile/directives/header) directive.
- In v1, you could only filter (or "match") directives by request path. In v2, [request matching](/docs/caddyfile/matchers) is much more powerful. Any v2 directives which add a middleware to the HTTP handler chain or which manipulate the HTTP request/response in any way take advantage of this new matching functionality. [Read more about v2 request matchers.](/docs/caddyfile/matchers) You'll need to know about them to make sense of the v2 Caddyfile.
@ -116,6 +116,23 @@ We'll list some of the most common v1 directives here and describe how to conver
⚠️ **Just because a v1 directive is missing from this page does not mean v2 can't do it!** Some v1 directives aren't needed, don't translate well, or are fulfilled other ways in v2. For some advanced customization, you may need to drop down to the JSON to get what you want. Explore [our documentation](/docs/caddyfile) to find what you need!
### basicauth
HTTP Basic Authentication is still configured with the [`basicauth`](/docs/caddyfile/directives/basicauth) directive. However, Caddy 2 configuration does not accept plaintext passwords. You must hash them, which the [`caddy hash-password`](/docs/command-line#caddy-hash-password) can help with.
- **v1:**
```
basicauth /secret/ Bob hiccup
```
- **v2:**
```
basicauth /secret/* {
Bob JDJhJDEwJEVCNmdaNEg2Ti5iejRMYkF3MFZhZ3VtV3E1SzBWZEZ5Q3VWc0tzOEJwZE9TaFlZdEVkZDhX
}
```
### browse
File browsing is now enabled through the [`file_server`](/docs/caddyfile/directives/file_server) directive.