machine-config/bert/services/http/chandlerswift.com.nix
Chandler Swift 437097a71b
bert: Add chandlerswift.com cloudflare compat redir
Cloudflare Pages, the previous home of this site, strips the `.html`
suffix from filenames (no small part of the reason this site was moved!)
e.g. a recent post would be served on

https://chandlerswift.com/2024/11/12/install-lineageos-on-lemonade

and not on

https://chandlerswift.com/2024/11/12/install-lineageos-on-lemonade.html

and the latter would be redirected to the former.

To me, this seems like a perversion of file paths for no good reason,
and it seems that a not-insubstantial chunk of the internet agrees:

https://community.cloudflare.com/search?q=%22.html%22%20%23developers%3Acloudflare-pages

This has been repeatedly considered "feature not bug" (despite examples
of use cases the feature breaks), e.g.

https://github.com/cloudflare/workers-sdk/issues/1488

This PR used AI assistance (and manual verification) for Caddyfile
syntax:

https://chatgpt.com/share/67a6d4e5-a464-800c-9c4d-910faa53b2dd
2025-02-07 21:53:37 -06:00

30 lines
840 B
Nix

{
services.caddy.virtualHosts."chandlerswift.com".extraConfig = ''
encode zstd gzip
file_server
root * /srv/www/chandlerswift.com
# hide .git # ???
@html_redirect {
file {path}.html
not path *.html
}
redir @html_redirect {path}.html 301
redir /.well-known/host-meta* https://social.chandlerswift.com{uri} permanent
redir /.well-known/webfinger* https://social.chandlerswift.com{uri} permanent
redir /.well-known/nodeinfo* https://social.chandlerswift.com{uri} permanent
handle_errors {
respond "{err.status_code} {err.status_text}"
}
'';
services.caddy.virtualHosts."www.chandlerswift.com".extraConfig = "redir https://chandlerswift.com{uri}";
systemd.tmpfiles.settings."10-chandlerswift-com" = {
"/srv/www/chandlerswift.com" = {
d = {};
};
};
}