nix-config/hosts/hetznix/services/caddy/vhosts/www.oliverdavies.uk.nix

44 lines
957 B
Nix
Raw Normal View History

2024-12-26 00:13:42 +00:00
{
services.caddy.virtualHosts = {
"oliverdavies.uk" = {
useACMEHost = "oliverdavies.uk";
extraConfig = ''
redir https://www.oliverdavies.uk{uri}
'';
};
"www.oliverdavies.uk" = {
useACMEHost = "oliverdavies.uk";
2025-04-16 22:00:52 +01:00
extraConfig =
''
encode gzip
2024-12-26 00:13:42 +00:00
2025-04-16 22:00:52 +01:00
root * /var/www/vhosts/www.oliverdavies.uk
2024-12-26 00:13:42 +00:00
2025-04-16 22:00:52 +01:00
file_server {
disable_canonical_uris
2024-12-26 00:13:42 +00:00
}
2025-04-16 22:00:52 +01:00
# Remove trailing slashes from all URLs.
@trailingSlash {
path_regexp trailingSlash ^(.*)/$
not path /
}
redir @trailingSlash {http.regexp.trailingSlash.1} temporary
2025-04-16 22:00:52 +01:00
handle_errors {
@404 {
expression {http.error.status_code} == 404
}
2024-12-26 00:13:42 +00:00
2025-04-16 22:00:52 +01:00
rewrite @404 /404/index.html
file_server
}
''
+ builtins.readFile ./www.oliverdavies.uk-redirects.caddy;
2024-12-26 00:13:42 +00:00
};
};
}