From e59dbe314f608da3fca21fdad2643e5626e0f94e Mon Sep 17 00:00:00 2001 From: Florian Zirker Date: Tue, 10 Dec 2024 16:29:08 +0100 Subject: [PATCH] handle errors --- proxy/caddy/Caddyfile | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/proxy/caddy/Caddyfile b/proxy/caddy/Caddyfile index 7b20b5d..4cc073c 100644 --- a/proxy/caddy/Caddyfile +++ b/proxy/caddy/Caddyfile @@ -6,6 +6,15 @@ } } +(error) { + root * /usr/share/caddy + rewrite * /error.html + templates + file_server { + status {err.status_code} + } +} + *.{$DOMAIN} { tls { dns netcup { @@ -79,7 +88,23 @@ # Fallback for otherwise unhandled domains handle { - respond 404 + respond "404 Not Found" 404 + } + + # handle wrong url pathes + handle_errors 404 { + #respond "{err.status_code} {err.status_text}" {err.status_code} + import error + } + + # handle errors of proxy backends are down + # handle_errors 502 { + # respond "503 Service Unavailable" 503 + # } + + # every other error + handle_errors { + import error } }