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

72 lines
1.8 KiB
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 =
let
2025-04-17 08:29:58 +01:00
tomePaths = [
"core"
"sites/default/files"
"themes/custom/opdavies"
"tome-test"
];
tomeConfig = builtins.concatStringsSep "\n\n" (
builtins.map (path: ''
handle /${path} {
root * /var/www/vhosts/www.oliverdavies.uk-tome
file_server
}
handle_path /${path}/* {
root * /var/www/vhosts/www.oliverdavies.uk-tome/${path}
file_server
}
'') tomePaths
);
redirects = import ./www.oliverdavies.uk-redirects.nix;
redirectLines = builtins.concatStringsSep "\n" (
map (r: "redir ${r.from} ${r.to} permanent") redirects
);
in
2025-04-16 22:00:52 +01:00
''
encode gzip
file_server
2025-04-16 22:25:47 +01:00
root * /var/www/vhosts/www.oliverdavies.uk-sculpin
2024-12-26 00:13:42 +00:00
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
}
${tomeConfig}
@articles path_regexp ^/articles/(.*)$
@talks path_regexp ^/talks/(.*)$
@talks-archive path_regexp ^/talks/archive/(.*)$
redir @articles /blog/{re.1} permanent
redir @talks-archive /presentations/{re.1} permanent
redir @talks /presentations/{re.1} permanent
${redirectLines}
'';
2024-12-26 00:13:42 +00:00
};
};
}