caddy: init

This commit is contained in:
Nico 2025-05-03 16:16:03 +10:00
parent 2dd3ade483
commit 25f02ec9ee
6 changed files with 118 additions and 25 deletions

View file

@ -23,6 +23,7 @@
./modules/nix/linux.nix ./modules/nix/linux.nix
./modules/shell.nix ./modules/shell.nix
./modules/services/caddy.nix
./modules/services/miniflux.nix ./modules/services/miniflux.nix
./modules/services/media/arr.nix ./modules/services/media/arr.nix
./modules/services/media/jellyfin.nix ./modules/services/media/jellyfin.nix

View file

@ -0,0 +1,34 @@
{ pkgs, config, lib, ... }:
{
options = {
homelab.domain = lib.mkOption {
type = lib.types.str;
};
};
config = {
homelab.domain = "nyanyanya.myaddr.io";
networking.firewall.allowedTCPPorts = [ 80 443 ];
services.caddy = {
enable = true;
};
security.acme = {
acceptTerms = true;
defaults.email = "nicocute@proton.me";
certs."${config.homelab.domain}" = {
group = config.services.caddy.group;
domain = "${config.homelab.domain}";
extraDomainNames = [ "*.${config.homelab.domain}" ];
dnsProvider = "myaddr";
dnsResolver = "1.1.1.1:53";
dnsPropagationCheck = true;
environmentFile = /var/lib/caddy/secret;
};
};
};
}

View file

@ -3,9 +3,9 @@
{ {
services.glance = { services.glance = {
enable = true; enable = true;
settings.server.port = 80; settings.server.port = 8888;
settings.server.host = "0.0.0.0"; settings.server.host = "0.0.0.0";
openFirewall = true; openFirewall = false;
settings = { settings = {
pages = [ pages = [
{ {
@ -57,35 +57,35 @@
links = [ links = [
{ {
title = "Jellyfin"; title = "Jellyfin";
url = "http://${config.networking.hostName}:8096"; url = "https://watch.${config.homelab.domain}";
} }
{ {
title = "Jellyseer"; title = "Jellyseer";
url = "http://${config.networking.hostName}:5055"; url = "https://jellyseer.${config.homelab.domain}";
} }
{ {
title = "Radarr"; title = "Radarr";
url = "http://${config.networking.hostName}:7878"; url = "https://radarr.${config.homelab.domain}";
} }
{ {
title = "Sonarr"; title = "Sonarr";
url = "http://${config.networking.hostName}:8989"; url = "https://sonarr.${config.homelab.domain}";
} }
{ {
title = "Lidarr"; title = "Lidarr";
url = "http://${config.networking.hostName}:8686"; url = "https://lidarr.${config.homelab.domain}";
} }
{ {
title = "Prowlarr"; title = "Prowlarr";
url = "http://${config.networking.hostName}:9696"; url = "https://prowlarr.${config.homelab.domain}";
} }
{ {
title = "Bazarr"; title = "Bazarr";
url = "http://${config.networking.hostName}:6767"; url = "https://bazarr.${config.homelab.domain}";
} }
{ {
title = "Deluge"; title = "Deluge";
url = "http://${config.networking.hostName}:8112"; url = "https://deluge.${config.homelab.domain}";
} }
]; ];
} }
@ -95,7 +95,7 @@
links = [ links = [
{ {
title = "Miniflux"; title = "Miniflux";
url = "http://${config.networking.hostName}:8021"; url = "https://rss.${config.homelab.domain}";
} }
]; ];
} }
@ -109,6 +109,10 @@
}; };
}; };
# allow services to bind to port 80 services.caddy.virtualHosts."${config.homelab.domain}" = {
boot.kernel.sysctl."net.ipv4.ip_unprivileged_port_start" = 0; useACMEHost = config.homelab.domain;
extraConfig = ''
reverse_proxy http://localhost:8888
'';
};
} }

View file

@ -6,33 +6,33 @@
# Finding/Requesting downloading # Finding/Requesting downloading
services.radarr = { services.radarr = {
enable = true; enable = true;
openFirewall = true; openFirewall = false;
dataDir = "/var/lib/radarr"; dataDir = "/var/lib/radarr";
group = "media"; group = "media";
}; };
services.sonarr = { services.sonarr = {
enable = true; enable = true;
openFirewall = true; openFirewall = false;
dataDir = "/var/lib/sonarr"; dataDir = "/var/lib/sonarr";
group = "media"; group = "media";
}; };
services.lidarr = { services.lidarr = {
enable = true; enable = true;
openFirewall = true; openFirewall = false;
dataDir = "/var/lib/lidarr"; dataDir = "/var/lib/lidarr";
group = "media"; group = "media";
}; };
services.prowlarr = { services.prowlarr = {
enable = true; enable = true;
openFirewall = true; openFirewall = false;
}; };
services.bazarr = { services.bazarr = {
enable = true; enable = true;
openFirewall = true; openFirewall = false;
group = "media"; group = "media";
}; };
@ -40,7 +40,7 @@
services.deluge = { services.deluge = {
enable = true; enable = true;
web.enable = true; web.enable = true;
web.openFirewall = true; web.openFirewall = false;
group = "media"; group = "media";
}; };
@ -49,7 +49,50 @@
services.jellyseerr = { services.jellyseerr = {
enable = true; enable = true;
port = 5055; port = 5055;
openFirewall = true; openFirewall = false;
package = pkgs.jellyseerr; package = pkgs.jellyseerr;
}; };
services.caddy.virtualHosts."radarr.${config.homelab.domain}" = {
useACMEHost = config.homelab.domain;
extraConfig = ''
reverse_proxy http://localhost:7878
'';
};
services.caddy.virtualHosts."sonarr.${config.homelab.domain}" = {
useACMEHost = config.homelab.domain;
extraConfig = ''
reverse_proxy http://localhost:8989
'';
};
services.caddy.virtualHosts."lidarr.${config.homelab.domain}" = {
useACMEHost = config.homelab.domain;
extraConfig = ''
reverse_proxy http://localhost:8686
'';
};
services.caddy.virtualHosts."prowlarr.${config.homelab.domain}" = {
useACMEHost = config.homelab.domain;
extraConfig = ''
reverse_proxy http://localhost:9696
'';
};
services.caddy.virtualHosts."bazarr.${config.homelab.domain}" = {
useACMEHost = config.homelab.domain;
extraConfig = ''
reverse_proxy http://localhost:6767
'';
};
services.caddy.virtualHosts."deluge.${config.homelab.domain}" = {
useACMEHost = config.homelab.domain;
extraConfig = ''
reverse_proxy http://localhost:8112
'';
};
services.caddy.virtualHosts."jellyseer.${config.homelab.domain}" = {
useACMEHost = config.homelab.domain;
extraConfig = ''
reverse_proxy http://localhost:5055
'';
};
} }

View file

@ -1,10 +1,17 @@
{ ... }: { config, ... }:
{ {
# Streaming frontend # Streaming frontend
services.jellyfin = { services.jellyfin = {
enable = true; enable = true;
openFirewall = true; openFirewall = false;
group = "media"; group = "media";
}; };
services.caddy.virtualHosts."watch.${config.homelab.domain}" = {
# useACMEHost = config.homelab.domain;
extraConfig = ''
reverse_proxy http://localhost:8096
'';
};
} }

View file

@ -11,7 +11,7 @@
config = { config = {
LISTEN_ADDR = "0.0.0.0:8021"; LISTEN_ADDR = "0.0.0.0:8021";
BASE_URL = "http://${config.networking.hostName}"; BASE_URL = "http://rss.${config.homelab.domain}";
CLEANUP_FREQUENCY = 48; CLEANUP_FREQUENCY = 48;
CREATE_ADMIN = 1; CREATE_ADMIN = 1;
@ -34,6 +34,10 @@
}; };
}; };
networking.firewall.allowedTCPPorts = [ 8021 ]; services.caddy.virtualHosts."rss.${config.homelab.domain}" = {
networking.firewall.allowedUDPPorts = [ 8021 ]; useACMEHost = config.homelab.domain;
extraConfig = ''
reverse_proxy http://localhost:8021
'';
};
} }