nixos-config/linux/singularity/caddy.nix

80 lines
2.2 KiB
Nix
Raw Normal View History

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