new dns routing
This commit is contained in:
1 parent
045702e909
commit
4f396d93c4
10 files changed
+87
-19
No files matched your search
+1
-1
@@ -37,7 +37,7 @@ hosts/
|
||||
| `hl-bigbox2/` | hl-bigbox2 | NFS storage server |
|
||||
| `hl-minipc1/` | hl-minipc1 | Core infra: Gitea, nix-serve, registry, Buzz (docker, `buzz-manage` CLI) |
|
||||
| `hl-minipc2/` | hl-minipc2 | Container/media server |
|
||||
| `hl-minipc3/` | hl-minipc3 | K3s worker node |
|
||||
| `hl-minipc3/` | hl-minipc3 | K3s worker node; central Caddy reverse-proxy (`*.home.sosnovsky.ca`) |
|
||||
| `hl-pi1/` | hl-pi1 | Raspberry Pi CM4 (aarch64) — headless server, SSH only |
|
||||
| `hl-pi2/` | hl-pi2 | Raspberry Pi 4 (aarch64) — headless server, SSH only |
|
||||
| `hl-terra1/` | hl-terra1 | NFS storage + Jellyfin backup |
|
||||
|
||||
@@ -10,7 +10,7 @@ let
|
||||
app = config.skyg.internalNetworkingMap.apps.buzz;
|
||||
buzz = {
|
||||
domain = app.effectiveDns;
|
||||
publicDomain = app.aliasDns;
|
||||
publicDomain = builtins.elemAt app.aliases 0;
|
||||
port = 3000;
|
||||
ip = app.ip;
|
||||
bucket = "buzz-media";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{ config, skyg-secrets, ... }:
|
||||
{ skyg-secrets, ... }:
|
||||
{
|
||||
imports = [
|
||||
./hardware-configuration
|
||||
@@ -19,7 +19,10 @@
|
||||
enable = true;
|
||||
envPath = "/opt/k3s/k3s.env";
|
||||
};
|
||||
|
||||
skyg.nixos.common.containers.networks.ipvlanLab = {
|
||||
enable = true;
|
||||
parent = "eno1";
|
||||
};
|
||||
age.secrets.portainer-agent-minipc3.file = skyg-secrets.portainer-agent-minipc3;
|
||||
skyg.nixos.server.portainer = {
|
||||
enable = true;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{ config, pkgs, skyg-secrets, ... }:
|
||||
{
|
||||
age.secrets.cloudflare-dns.file = skyg-secrets.cloudflare-dns;
|
||||
|
||||
skyg.server.acme = {
|
||||
enable = true;
|
||||
credentialsFile = config.age.secrets.cloudflare-dns.path;
|
||||
certs."home.sosnovsky.ca" = {
|
||||
extraDomains = [ "*.home.sosnovsky.ca" ];
|
||||
postRun = "${pkgs.docker}/bin/docker restart caddy-caddy-1";
|
||||
orderBefore = [ "container-services-caddy" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
{ config, ... }:
|
||||
let
|
||||
app = config.skyg.internalNetworkingMap.apps.caddy;
|
||||
nvr = config.skyg.internalNetworkingMap.apps.nvr;
|
||||
jellyfin = config.skyg.internalNetworkingMap.apps.jellyfin;
|
||||
portainer = config.skyg.internalNetworkingMap.apps.portainer;
|
||||
certDomain = "home.sosnovsky.ca";
|
||||
in
|
||||
{
|
||||
skyg.nixos.common.container-services.caddy = {
|
||||
enable = true;
|
||||
autoUpdate.enable = true;
|
||||
networks.lan = config.skyg.nixos.common.containers.networks.ipvlanLab.compose;
|
||||
services.caddy = {
|
||||
image = "caddy:2-alpine";
|
||||
networks.lan.ipv4_address = app.ip;
|
||||
files."/etc/caddy/Caddyfile" = ''
|
||||
nvr.home.sosnovsky.ca {
|
||||
tls /etc/caddy/tls/fullchain.pem /etc/caddy/tls/key.pem
|
||||
reverse_proxy ${nvr.ip}:80
|
||||
}
|
||||
jellyfin.home.sosnovsky.ca {
|
||||
tls /etc/caddy/tls/fullchain.pem /etc/caddy/tls/key.pem
|
||||
reverse_proxy http://bigbox1.lab.internal:8096
|
||||
}
|
||||
portainer.home.sosnovsky.ca {
|
||||
tls /etc/caddy/tls/fullchain.pem /etc/caddy/tls/key.pem
|
||||
reverse_proxy ${portainer.ip}:9000
|
||||
}
|
||||
'';
|
||||
volumes = [
|
||||
"/var/lib/acme/${certDomain}/fullchain.pem:/etc/caddy/tls/fullchain.pem:ro"
|
||||
"/var/lib/acme/${certDomain}/key.pem:/etc/caddy/tls/key.pem:ro"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
imports = [
|
||||
./caddy.nix
|
||||
./acme.nix
|
||||
];
|
||||
}
|
||||
@@ -15,7 +15,7 @@ let
|
||||
# behaviour the generator expects for Nix-declared names.
|
||||
toRecord = name: app: {
|
||||
ip = app.ip;
|
||||
domains = [ app.effectiveDns ] ++ lib.optional (app.aliasDns != null) app.aliasDns;
|
||||
domains = [ app.effectiveDns ] ++ app.aliases;
|
||||
wildcard = false;
|
||||
source = "internalNetworkingMap/${name}";
|
||||
};
|
||||
|
||||
+16
-8
@@ -20,11 +20,11 @@ let
|
||||
description = "LAN IPv4 address of the app.";
|
||||
};
|
||||
|
||||
aliasDns = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
example = "buzz.home.sosnovsky.ca";
|
||||
description = "Optional public/alternate DNS name for the app.";
|
||||
aliases = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ ];
|
||||
example = [ "buzz.home.sosnovsky.ca" ];
|
||||
description = "Optional public/alternate DNS names for the app.";
|
||||
};
|
||||
|
||||
effectiveDns = lib.mkOption {
|
||||
@@ -105,11 +105,19 @@ in
|
||||
};
|
||||
apps = {
|
||||
drawdb = { ip = "10.0.101.2"; };
|
||||
buzz = { ip = "10.0.101.3"; aliasDns = "buzz.home.sosnovsky.ca"; };
|
||||
buzz = { ip = "10.0.101.3"; aliases = [ "buzz.home.sosnovsky.ca" ]; };
|
||||
audiobooks = { ip = "10.0.101.4"; };
|
||||
# jellyfin = { ip = "10.0.101.5"; aliasDns = "jellyfin.home.sosnovsky.ca"; };
|
||||
nvr = { ip = "10.0.101.6"; aliasDns = "nvr.home.sosnovsky.ca"; };
|
||||
jellyfin = { ip = "10.0.101.5"; };
|
||||
nvr = { ip = "10.0.101.6"; };
|
||||
portainer = { ip = "10.0.101.241"; };
|
||||
caddy = {
|
||||
ip = "10.0.101.7";
|
||||
aliases = [
|
||||
"nvr.home.sosnovsky.ca"
|
||||
"jellyfin.home.sosnovsky.ca"
|
||||
"portainer.home.sosnovsky.ca"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -236,11 +236,11 @@ skyg.nixos.common.container-services.drawdb.services.drawdb = {
|
||||
};
|
||||
```
|
||||
|
||||
| Field | Notes |
|
||||
| -------------- | ---------------------------------------------------------------------- |
|
||||
| `ip` | LAN IPv4 address the app's names resolve to. |
|
||||
| `aliasDns` | Optional extra name (e.g. a public domain) that also resolves to `ip`. |
|
||||
| `effectiveDns` | Read-only; computed as `<app-name>` + `rootDns`. |
|
||||
| Field | Notes |
|
||||
| -------------- | --------------------------------------------------------------------- |
|
||||
| `ip` | LAN IPv4 address the app's names resolve to. |
|
||||
| `aliases` | Optional extra names (e.g. public domains) that also resolve to `ip`. |
|
||||
| `effectiveDns` | Read-only; computed as `<app-name>` + `rootDns`. |
|
||||
|
||||
Verify and deploy:
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ in
|
||||
"secrets/buzz-env.age".publicKeys = [ ari minipc1 ];
|
||||
|
||||
# Cloudflare DNS API token for ACME DNS-01 (skyg.server.acme)
|
||||
"secrets/cloudflare-dns.age".publicKeys = [ ari minipc1 ];
|
||||
"secrets/cloudflare-dns.age".publicKeys = [ ari minipc1 minipc3 ];
|
||||
|
||||
# stack compose definition — minipc2
|
||||
"secrets/stack1.age".publicKeys = [ ari minipc2 ];
|
||||
|
||||
Reference in new issue
Block a user