From 5282fbd6ffae51a45861aae042aac4b8d062cf31 Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Mon, 17 Oct 2022 19:24:39 +0200 Subject: [PATCH] Add another handle_errors example (#273) --- .../markdown/caddyfile/directives/handle_errors.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/docs/markdown/caddyfile/directives/handle_errors.md b/src/docs/markdown/caddyfile/directives/handle_errors.md index d1fe8f5..ac8de13 100644 --- a/src/docs/markdown/caddyfile/directives/handle_errors.md +++ b/src/docs/markdown/caddyfile/directives/handle_errors.md @@ -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