Add another handle_errors example (#273)

This commit is contained in:
Tobias Gruetzmacher 2022-10-17 19:24:39 +02:00 committed by GitHub
parent af47d0574b
commit 5282fbd6ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -60,6 +60,20 @@ handle_errors {
}
```
If you want to provide custom error pages only for some error codes, you can check the existence of the custom error files beforehand with a [`file`](/docs/caddyfile/matchers#file) matcher:
```caddy-d
handle_errors {
@custom_err file /err-{http.error.status_code}.html /err.html
handle @custom_err {
rewrite @custom_err {http.matchers.file.relative}
file_server
}
respond "{http.error.status_code} {http.error.status_text}"
}
```
Reverse proxy to a professional server that is highly qualified for handling HTTP errors and improving your day 😸:
```caddy-d