2023-11-29 22:15:31 -05:00
|
|
|
{
|
|
|
|
caddy-plugins,
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
2024-08-11 14:53:45 -04:00
|
|
|
inherit (config.vars) hostName mainUser;
|
2024-01-09 13:13:04 -05:00
|
|
|
inherit (config.sops) secrets;
|
|
|
|
|
2023-11-29 22:15:31 -05:00
|
|
|
caddy = caddy-plugins.packages.${pkgs.system}.default;
|
|
|
|
in {
|
|
|
|
imports = [caddy-plugins.nixosModules.default];
|
2024-01-23 16:15:40 -05:00
|
|
|
|
|
|
|
# User stuff
|
2023-11-29 22:15:31 -05:00
|
|
|
environment.systemPackages = [caddy];
|
2024-01-09 13:13:04 -05:00
|
|
|
users.users.${mainUser}.extraGroups = ["caddy"];
|
2023-11-29 22:15:31 -05:00
|
|
|
|
2024-08-15 23:50:43 -04:00
|
|
|
boot.kernel.sysctl."net.ipv4.ip_nonlocal_bind" = 1;
|
|
|
|
|
2024-10-28 09:23:47 -04:00
|
|
|
systemd.services.caddy.serviceConfig = {
|
|
|
|
EnvironmentFile = secrets.caddy-cloudflare.path;
|
2023-12-21 15:09:34 -05:00
|
|
|
|
2024-10-28 09:23:47 -04:00
|
|
|
# For some reason the service
|
|
|
|
# doesn't shutdown normally
|
|
|
|
KillSignal = "SIGKILL";
|
|
|
|
RestartKillSignal = "SIGKILL";
|
2023-12-21 15:09:34 -05:00
|
|
|
};
|
2023-12-05 20:15:27 -05:00
|
|
|
|
2023-11-29 22:15:31 -05:00
|
|
|
services.caddy = {
|
|
|
|
enable = true;
|
|
|
|
enableReload = false;
|
|
|
|
package = caddy;
|
|
|
|
|
2023-12-21 15:09:34 -05:00
|
|
|
virtualHosts = let
|
2024-03-02 02:59:40 -05:00
|
|
|
clusterIP = config.services.pcsd.virtualIps.caddy-vip.ip;
|
|
|
|
nosIP = "10.0.0.121";
|
2024-03-02 03:09:42 -05:00
|
|
|
serviviIP = "10.0.0.249";
|
2024-09-01 19:19:30 -04:00
|
|
|
homieIP = "100.64.0.10";
|
2024-08-11 14:53:45 -04:00
|
|
|
|
|
|
|
tlsConf = ''
|
|
|
|
tls {
|
|
|
|
dns cloudflare {$CLOUDFLARE_API_TOKEN}
|
|
|
|
resolvers 1.0.0.1
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
|
|
|
mkPublicReverseProxy = subdomain: ip: extraConf:
|
|
|
|
{
|
|
|
|
hostName = "${subdomain}.nelim.org";
|
|
|
|
reverseProxy = ip;
|
|
|
|
listenAddresses = [clusterIP];
|
|
|
|
extraConfig = tlsConf + (extraConf.extraConfig or "");
|
|
|
|
}
|
|
|
|
// (builtins.removeAttrs extraConf ["extraConfig"]);
|
2023-12-21 15:09:34 -05:00
|
|
|
in {
|
2024-08-11 14:53:45 -04:00
|
|
|
# Public
|
2024-09-01 19:19:30 -04:00
|
|
|
"Home-Assistant" = mkPublicReverseProxy "homie" "${homieIP}:8123" {};
|
2024-08-11 14:53:45 -04:00
|
|
|
"Vaultwarden" = mkPublicReverseProxy "vault" "${nosIP}:8781" {};
|
|
|
|
"Hauk" = mkPublicReverseProxy "hauk" "${nosIP}:3003" {};
|
|
|
|
"Headscale" = mkPublicReverseProxy "headscale" "${clusterIP}:8085" {};
|
|
|
|
|
|
|
|
"Jellyfin" = mkPublicReverseProxy "jelly" "${nosIP}:8096" {
|
|
|
|
subDirectories.jfa-go = {
|
|
|
|
subDirName = "accounts";
|
|
|
|
reverseProxy = "${nosIP}:8056";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
"Jellyseer" = mkPublicReverseProxy "seerr" "${nosIP}:5055" {};
|
|
|
|
|
|
|
|
"Gameyfin" = mkPublicReverseProxy "games" "${nosIP}:8074" {};
|
|
|
|
|
|
|
|
"Forgejo" = mkPublicReverseProxy "git" "${nosIP}:3000" {};
|
|
|
|
|
|
|
|
"Nextcloud" = mkPublicReverseProxy "cloud" "${nosIP}:8042" {
|
2023-11-29 22:15:31 -05:00
|
|
|
extraConfig = ''
|
2024-08-11 14:53:45 -04:00
|
|
|
redir /.well-known/carddav /remote.php/dav 301
|
|
|
|
redir /.well-known/caldav /remote.php/dav 301
|
|
|
|
redir /.well-known/webfinger /index.php/.well-known/webfinger 301
|
|
|
|
redir /.well-known/nodeinfo /index.php/.well-known/nodeinfo 301
|
2023-11-29 22:15:31 -05:00
|
|
|
'';
|
2024-08-11 14:53:45 -04:00
|
|
|
};
|
|
|
|
"OnlyOffice" = mkPublicReverseProxy "office" "http://${nosIP}:8055" {};
|
2023-11-29 22:15:31 -05:00
|
|
|
|
2024-08-11 14:53:45 -04:00
|
|
|
"Immich" = mkPublicReverseProxy "photos" "${nosIP}:2283" {};
|
2024-05-22 14:30:34 -04:00
|
|
|
|
2024-08-30 12:30:35 -04:00
|
|
|
"Binary Cache" = mkPublicReverseProxy "cache" "${serviviIP}:5000" {};
|
|
|
|
|
2024-08-11 14:53:45 -04:00
|
|
|
# Private
|
|
|
|
"nelim.org" = {
|
|
|
|
serverAliases = ["*.nelim.org"];
|
|
|
|
extraConfig = tlsConf;
|
|
|
|
listenAddresses = [
|
|
|
|
(
|
|
|
|
if hostName == "thingone"
|
|
|
|
then "100.64.0.8"
|
|
|
|
else "100.64.0.9"
|
|
|
|
)
|
|
|
|
];
|
2024-05-22 14:30:34 -04:00
|
|
|
|
2024-08-11 14:53:45 -04:00
|
|
|
subDomains = {
|
2024-09-02 23:24:04 -04:00
|
|
|
esphome.reverseProxy = "${homieIP}:6052";
|
2024-08-11 14:53:45 -04:00
|
|
|
pr-tracker.reverseProxy = "${serviviIP}:3000";
|
2023-11-29 22:15:31 -05:00
|
|
|
|
2024-03-10 20:04:04 -04:00
|
|
|
pcsd = {
|
|
|
|
extraConfig = ''
|
|
|
|
reverse_proxy https://${clusterIP}:2224 {
|
|
|
|
transport http {
|
|
|
|
tls_insecure_skip_verify
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-08-11 14:53:45 -04:00
|
|
|
# Resume builder
|
|
|
|
resume.reverseProxy = "${nosIP}:3060";
|
|
|
|
resauth.reverseProxy = "${nosIP}:3100";
|
2023-11-29 22:15:31 -05:00
|
|
|
|
|
|
|
# FreshRSS & Co
|
2024-03-19 09:23:50 -04:00
|
|
|
bridge.reverseProxy = "${nosIP}:3006";
|
2024-03-02 02:59:40 -05:00
|
|
|
drss.reverseProxy = "${nosIP}:3007";
|
2023-11-29 22:15:31 -05:00
|
|
|
freshrss = {
|
|
|
|
subDomainName = "rss";
|
2024-03-02 02:59:40 -05:00
|
|
|
reverseProxy = "${nosIP}:2800";
|
2023-11-29 22:15:31 -05:00
|
|
|
};
|
|
|
|
|
2024-03-02 02:59:40 -05:00
|
|
|
wgui.reverseProxy = "${nosIP}:51821";
|
2023-11-29 22:15:31 -05:00
|
|
|
|
|
|
|
lan = {
|
2024-03-02 02:59:40 -05:00
|
|
|
reverseProxy = "${nosIP}:3020";
|
2023-11-29 22:15:31 -05:00
|
|
|
extraConfig = ''
|
|
|
|
redir /index.html /
|
|
|
|
'';
|
|
|
|
|
|
|
|
subDirectories = {
|
2024-03-02 02:59:40 -05:00
|
|
|
bazarr.reverseProxy = "${nosIP}:6767";
|
|
|
|
prowlarr.reverseProxy = "${nosIP}:9696";
|
|
|
|
radarr.reverseProxy = "${nosIP}:7878";
|
|
|
|
sabnzbd.reverseProxy = "${nosIP}:8382";
|
|
|
|
sonarr.reverseProxy = "${nosIP}:8989";
|
2023-11-29 22:15:31 -05:00
|
|
|
|
|
|
|
qbittorent = {
|
|
|
|
subDirName = "qbt";
|
|
|
|
experimental = true;
|
2024-03-02 02:59:40 -05:00
|
|
|
reverseProxy = "${nosIP}:8080";
|
2023-11-29 22:15:31 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
vaultwarden = {
|
|
|
|
subDirName = "vault";
|
|
|
|
experimental = true;
|
2024-03-02 02:59:40 -05:00
|
|
|
reverseProxy = "${nosIP}:8780";
|
2023-11-29 22:15:31 -05:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# Top secret Business
|
|
|
|
joal.extraConfig = ''
|
|
|
|
route {
|
|
|
|
rewrite * /joal/ui{uri}
|
2024-03-02 02:59:40 -05:00
|
|
|
reverse_proxy * ${nosIP}:5656
|
2023-11-29 22:15:31 -05:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
joalws.extraConfig = ''
|
|
|
|
route {
|
2024-03-02 02:59:40 -05:00
|
|
|
reverse_proxy ${nosIP}:5656
|
2023-11-29 22:15:31 -05:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|