{ config, service_configs, username, pkgs, ... }: { services.caddy = { enable = true; email = "titaniumtown@proton.me"; virtualHosts = { ${service_configs.https.domain} = { extraConfig = '' root * ${service_configs.https.data_dir} file_server browse ''; serverAliases = [ "www.${service_configs.https.domain}" ]; }; "immich.${service_configs.https.domain}".extraConfig = '' reverse_proxy :${builtins.toString config.services.immich.port} ''; "jellyfin.${service_configs.https.domain}".extraConfig = '' reverse_proxy :${builtins.toString service_configs.ports.jellyfin} request_body { max_size 4096MB } ''; ${service_configs.gitea.domain}.extraConfig = '' reverse_proxy :${builtins.toString config.services.gitea.settings.server.HTTP_PORT} ''; "bitmagnet.${service_configs.https.domain}".extraConfig = '' # tls internal ${import ../secrets/caddy_auth.nix} reverse_proxy ${service_configs.https.wg_ip}:${builtins.toString service_configs.ports.bitmagnet} ''; "torrent.${service_configs.https.domain}".extraConfig = '' # tls internal ${import ../secrets/caddy_auth.nix} reverse_proxy ${service_configs.https.wg_ip}:${builtins.toString service_configs.ports.torrent} ''; "map.${service_configs.https.domain}".extraConfig = '' # tls internal root * ${service_configs.minecraft.parent_dir}/${service_configs.minecraft.server_name}/squaremap/web file_server browse ''; "${config.services.matrix-conduit.settings.global.server_name}".extraConfig = '' reverse_proxy :${builtins.toString config.services.matrix-conduit.settings.global.port} ''; # Exact duplicate of matrix.gardling.com "${config.services.matrix-conduit.settings.global.server_name}:8448".extraConfig = config.services.caddy.virtualHosts."${config.services.matrix-conduit.settings.global.server_name }".extraConfig; }; }; systemd.tmpfiles.rules = [ "d ${service_configs.https.data_dir} 0750 ${config.services.caddy.user} ${config.services.caddy.group}" ]; systemd.packages = with pkgs; [ nssTools ]; networking.firewall.allowedTCPPorts = [ service_configs.ports.https # http (but really acmeCA challenges) 80 # for matrix federation 8448 ]; networking.firewall.allowedUDPPorts = [ service_configs.ports.https # for matrix federation 8448 ]; users.users.${config.services.caddy.user}.extraGroups = [ # for `map.gardling.com` "minecraft" ]; users.users.${username}.extraGroups = [ config.services.caddy.group ]; }