Handle 404 in Caddy

This commit is contained in:
Jan Kremer 2026-03-27 07:19:52 +01:00
parent 3a561cd1aa
commit 11d6faae70
No known key found for this signature in database
2 changed files with 43 additions and 34 deletions

View file

@ -4,26 +4,33 @@
];
services.caddy.virtualHosts = {
"jankremer.de".extraConfig = ''
handle {
root * /var/www/jankremer.de
file_server
"jankremer.de".extraConfig = # caddyfile
''
handle {
root * /var/www/jankremer.de
file_server
@static {
path *.css *.js *.woff2 *.woff *.ttf *.png *.jpg *.jpeg *.svg *.ico *.webp
@static {
path *.css *.js *.woff2 *.woff *.ttf *.png *.jpg *.jpeg *.svg *.ico *.webp
}
header @static Cache-Control "public, max-age=31536000, immutable"
@html {
path *.html
}
header @html Cache-Control "no-cache"
handle_errors {
rewrite * /404.html
file_server
}
}
header @static Cache-Control "public, max-age=31536000, immutable"
'';
@html {
path *.html
}
header @html Cache-Control "no-cache"
}
'';
"jankremer.eu".extraConfig = ''
redir https://jankremer.de{uri} permanent
'';
"jankremer.eu".extraConfig = # caddyfile
''
redir https://jankremer.de{uri} permanent
'';
};
networking.firewall.allowedTCPPorts = [