nixos-config/linux/singularity/caddy.nix

70 lines
2 KiB
Nix
Raw Normal View History

2023-12-06 21:46:16 -08:00
{ config, pkgs, ... }:
2023-10-09 10:44:07 -07:00
{
services.caddy = {
enable = true;
email = config.constants.postMaster;
virtualHosts =
let
dn = config.constants.domain;
2024-04-12 12:05:44 -07:00
homeSrv = s: "nebula:${portStr.${s}}";
localSrv = s: "${config.constants.localhost}:${portStr.${s}}";
2023-10-09 10:44:07 -07:00
msfqdn = config.mailserver.fqdn;
mtfqdn = "matrix.${dn}";
2023-12-06 21:46:16 -08:00
portStr = builtins.mapAttrs (n: v: toString v) config.constants.port;
2023-10-09 10:44:07 -07:00
wn = s: "/.well-known/${s}";
in
{
"${dn}".extraConfig = let wnm = wn "matrix"; in ''
header ${wnm}/* Content-Type application/json
header ${wnm}/* Access-Control-Allow-Origin *
2023-12-06 21:46:16 -08:00
respond ${wnm}/server `{ "m.server": "${mtfqdn}:${portStr.https}" }`
2023-10-09 10:44:07 -07:00
respond ${wnm}/client `{
"m.homeserver": { "base_url": "https://${mtfqdn}" },
"m.identity_server": { "base_url": "https://${mtfqdn}" }
}`
'';
2023-12-06 21:46:16 -08:00
"forgejo.${dn}".extraConfig = ''
2024-04-12 12:05:44 -07:00
reverse_proxy ${homeSrv "forgejo"}
2023-12-06 21:46:16 -08:00
'';
2023-11-27 21:44:04 -08:00
"headscale.${dn}".extraConfig = ''
2024-04-12 12:05:44 -07:00
reverse_proxy ${localSrv "headscale"}
2023-12-06 21:46:16 -08:00
'';
"jellyfin.${dn}".extraConfig = ''
2024-04-12 12:05:44 -07:00
reverse_proxy ${homeSrv "jellyfin"}
2023-11-27 21:44:04 -08:00
'';
2023-10-09 10:44:07 -07:00
${msfqdn} = {
extraConfig = ''
file_server ${wn "acme-challenge"}/* {
root ${config.security.acme.defaults.webroot}/
}
'';
useACMEHost = msfqdn;
};
2023-12-06 21:46:16 -08:00
"matrix.${dn}".extraConfig = ''
2024-04-12 12:05:44 -07:00
reverse_proxy /_matrix/* ${homeSrv "conduit"}
2023-12-06 21:46:16 -08:00
file_server {
root ${pkgs.cinny}
}
'';
2024-03-08 20:14:20 -08:00
"vault.${dn}".extraConfig = ''
2024-04-12 12:05:44 -07:00
reverse_proxy ${localSrv "vault"} {
2024-03-08 20:14:20 -08:00
header_up X-Real-IP {remote_host}
}
'';
"writefreely.${dn}".extraConfig = ''
2024-04-12 12:05:44 -07:00
reverse_proxy ${homeSrv "writefreely"}
2024-03-08 20:14:20 -08:00
'';
2023-10-09 10:44:07 -07:00
};
};
security.acme = {
acceptTerms = true;
defaults = {
email = config.constants.postMaster;
webroot = "/var/lib/acme/acme-challenge";
};
};
}