{ config, ... }: let # TODO: mkVHost aliasDir = url: path: { "${url}" = { return = "301 ${url}/"; }; "${url}/".alias = "${path}/"; }; in { imports = [ ../../services/nginx.nix ../../services/prometheus-nginx.nix ]; services.nginx.virtualHosts = { "mta-sts.${config.networking.domain}" = { quic = true; kTLS = true; forceSSL = true; enableACME = true; extraConfig = '' add_header Strict-Transport-Security max-age=15768000; ''; locations."= /.well-known/mta-sts.txt" = { alias = "/srv/http/mta-sts.txt"; extraConfig = '' default_type text/plain; ''; }; }; "www.${config.networking.domain}" = { default = true; serverAliases = [ config.networking.domain ]; quic = true; kTLS = true; forceSSL = true; enableACME = true; extraConfig = '' # HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months) add_header Strict-Transport-Security max-age=15768000; ''; locations = { "/" = { root = "/srv/http/www"; index = "index.html"; tryFiles = "$uri $uri/ $uri.html =404"; }; "= /.well-known/security.txt" = { alias = "/srv/http/security.txt"; extraConfig = '' default_type text/plain; ''; }; "/.well-known/matrix/client" = { return = "200 '{\"m.homeserver\":{\"base_url\":\"https://matrix.berlin.ccc.de\"}}'"; extraConfig = '' add_header Access-Control-Allow-Origin "*"; default_type application/json; ''; }; "/.well-known/matrix/server" = { return = "200 '{\"m.server\":\"matrix.berlin.ccc.de:443\"}'"; extraConfig = '' add_header Access-Control-Allow-Origin "*"; default_type application/json; ''; }; "~ ^/~(.+?)" = { root = "/srv/http/homes"; index = "index.html"; tryFiles = "$uri $uri/ $uri.html =404"; extraConfig = '' autoindex on; ''; }; "/all.ics" = { return = "301 https://$host/calendars/all.ics"; }; "~ ^/calendars/([^/]+\.ics)$" = { alias = "/srv/http/calendars/$1"; extraConfig = '' add_header Cache-Control "no-cache"; types { text/calendar ics; } default_type text/calendar; ''; }; } // aliasDir "/twentyyears" "/srv/http/twentyyears" // aliasDir "/thirtytwoyears" "/srv/http/thirtytwoyears" // aliasDir "/kik" "/srv/http/kik" # RFC8805 // aliasDir "/noc" "/srv/http/noc" // aliasDir "/static" "/srv/http/static" # RFC8805 new location // aliasDir "/.well-known/loc" "/srv/http/noc"; }; "staging.${config.networking.domain}" = { quic = true; kTLS = true; forceSSL = true; enableACME = true; locations = { "/" = { basicAuthFile = config.age.secrets.www-staging-htpasswd.path; root = "/srv/http/www-staging"; index = "index.html"; tryFiles = "$uri $uri/ $uri.html =404"; }; "/all.ics" = { return = "301 https://$host/calendars/all.ics"; }; "~ ^/calendars/([^/]+\.ics)$" = { alias = "/srv/http/calendars/$1"; extraConfig = '' add_header Cache-Control "no-cache"; types { text/calendar ics; } default_type text/calendar; ''; }; }; }; }; }