diff --git a/src/docs/markdown/caddyfile/directives.md b/src/docs/markdown/caddyfile/directives.md index 26bdeb9..282f98b 100644 --- a/src/docs/markdown/caddyfile/directives.md +++ b/src/docs/markdown/caddyfile/directives.md @@ -13,6 +13,7 @@ Directive | Description **[encode](/docs/caddyfile/directives/encode)** | Encodes (usually compresses) responses **[file_server](/docs/caddyfile/directives/file_server)** | Serve files from disk **[handle](/docs/caddyfile/directives/handle)** | A mutually-exclusive group of directives +**[handle_errors](/docs/caddyfile/directives/handle_errors)** | Defines routes for handling errors **[header](/docs/caddyfile/directives/header)** | Sets or removes response headers **[log](/docs/caddyfile/directives/log)** | Enables access/request logging **[php_fastcgi](/docs/caddyfile/directives/php_fastcgi)** | Serve PHP sites over FastCGI diff --git a/src/docs/markdown/caddyfile/directives/file_server.md b/src/docs/markdown/caddyfile/directives/file_server.md index 85b1b80..37b246b 100644 --- a/src/docs/markdown/caddyfile/directives/file_server.md +++ b/src/docs/markdown/caddyfile/directives/file_server.md @@ -13,7 +13,7 @@ A static file server. It works by appending the request's URI path to the [site' file_server [] [browse] { root hide - index + index browse [] } ``` @@ -21,6 +21,7 @@ file_server [] [browse] { - **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. - **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` - **** is an optional custom template file to use for directory listings. diff --git a/src/docs/markdown/caddyfile/directives/handle_errors.md b/src/docs/markdown/caddyfile/directives/handle_errors.md new file mode 100644 index 0000000..8f63aab --- /dev/null +++ b/src/docs/markdown/caddyfile/directives/handle_errors.md @@ -0,0 +1,19 @@ +--- +title: handle_errors (Caddyfile directive) +--- + +# handle_errors + +Sets up error handlers. + +When the normal HTTP request handlers return an error, normal procesing stops and the error handlers are invoked. Error handlers form a route which is just like normal routes, and they can do anything that normal routes can do. This enables great control and flexibility when handling errors during HTTP requests. + +## Syntax + +``` +handle_errors { + +} +``` + +- **** is a list of HTTP handler directives, directive blocks, or matchers; one per line. diff --git a/src/docs/markdown/caddyfile/matchers.md b/src/docs/markdown/caddyfile/matchers.md index 92ec43f..fb4c8e5 100644 --- a/src/docs/markdown/caddyfile/matchers.md +++ b/src/docs/markdown/caddyfile/matchers.md @@ -121,6 +121,7 @@ For most matchers that accept multiple values, those values are OR'ed; i.e. one Full matcher documentation can be found [in each respective matcher module's docs](/docs/json/apps/http/servers/routes/match/). +- [expression](#expression) - [file](#file) - [header](#header) - [header_regexp](#header-regexp) @@ -134,6 +135,26 @@ Full matcher documentation can be found [in each respective matcher module's doc - [remote_ip](#remote-ip) + +### expression + +``` +expression +``` + +By any [CEL (Common Expression Language)](https://github.com/google/cel-spec) expression that returns `true` or `false`. + +⚠️ This module is still experimental and, as such, may experience breaking changes. + +As a special case, Caddy [placeholders](/docs/conventions#placeholders) (or [Caddyfile shorthands](/docs/caddyfile/concepts#placeholders)) may be used in these CEL expressions, as they are preprocessed and converted to regular CEL function calls before being interpreted by the CEL environment. + +Examples: + +``` +expression {method}.startsWith("P") +``` + + ### file ``` diff --git a/src/docs/markdown/v2-upgrade.md b/src/docs/markdown/v2-upgrade.md index 4002d5b..607f6a9 100644 --- a/src/docs/markdown/v2-upgrade.md +++ b/src/docs/markdown/v2-upgrade.md @@ -94,6 +94,8 @@ Environment variables are no longer relevant, except for `HOME` (and, optionally The [v2 Caddyfile](/docs/caddyfile/concepts) is very similar to what you're already familiar with. The main thing you'll need to do is change your directives. +⚠️ **Do not take this advice at face value!** Especially if your config is more advanced, there are many nuances to consider. These tips will get you mostly switched over pretty quickly, but please read the full documentation for each directive so you can understand the implications of the upgrade. And of course, always test your configs thoroughly before putting them into production. + ### Primary changes