caddy: wildcard TLS via DNS-01 challenge + ddns-updater for Njalla
Some checks failed
Build and Deploy / deploy (push) Failing after 31m3s
Some checks failed
Build and Deploy / deploy (push) Failing after 31m3s
Build Caddy with the caddy-dns/njalla plugin to enable DNS-01 ACME challenges. This issues a single wildcard certificate for *.sigkill.computer instead of per-subdomain certificates, reducing Let's Encrypt API calls and certificate management overhead. Add ddns-updater service (nixpkgs services.ddns-updater) configured with Njalla provider to automatically update DNS records when the server's public IP changes.
This commit is contained in:
@@ -71,6 +71,8 @@
|
||||
./services/mollysocket.nix
|
||||
|
||||
./services/harmonia.nix
|
||||
|
||||
./services/ddns-updater.nix
|
||||
];
|
||||
|
||||
# Hosts entries for CI/CD deploy targets
|
||||
|
||||
@@ -46,6 +46,20 @@
|
||||
group = "caddy";
|
||||
};
|
||||
|
||||
# Njalla API token (NJALLA_API_TOKEN=...) for Caddy DNS-01 challenge
|
||||
njalla-api-token-env = {
|
||||
file = ../secrets/njalla-api-token-env.age;
|
||||
mode = "0400";
|
||||
owner = "caddy";
|
||||
group = "caddy";
|
||||
};
|
||||
|
||||
# ddns-updater config.json with Njalla provider credentials
|
||||
ddns-updater-config = {
|
||||
file = ../secrets/ddns-updater-config.age;
|
||||
mode = "0400";
|
||||
};
|
||||
|
||||
jellyfin-api-key = {
|
||||
file = ../secrets/jellyfin-api-key.age;
|
||||
mode = "0400";
|
||||
|
||||
BIN
secrets/ddns-updater-config.age
Normal file
BIN
secrets/ddns-updater-config.age
Normal file
Binary file not shown.
BIN
secrets/njalla-api-token-env.age
Normal file
BIN
secrets/njalla-api-token-env.age
Normal file
Binary file not shown.
@@ -56,9 +56,19 @@ in
|
||||
enable = true;
|
||||
email = "titaniumtown@proton.me";
|
||||
|
||||
# Enable on-demand TLS for old domain redirects
|
||||
# Certs are issued dynamically when subdomains are accessed
|
||||
# Build with Njalla DNS provider for DNS-01 ACME challenges (wildcard certs)
|
||||
package = pkgs.caddy.withPlugins {
|
||||
plugins = [ "github.com/caddy-dns/njalla@v0.0.0-20250823094507-f709141f1fe6" ];
|
||||
hash = "sha256-rrOAR6noTDpV/I/hZXxhz0OXVJKu0mFQRq87RUrpmzw=";
|
||||
};
|
||||
|
||||
globalConfig = ''
|
||||
# Wildcard cert for *.${newDomain} via DNS-01 challenge
|
||||
acme_dns njalla {
|
||||
api_token {env.NJALLA_API_TOKEN}
|
||||
}
|
||||
|
||||
# On-demand TLS for old domain redirects
|
||||
on_demand_tls {
|
||||
ask http://localhost:9123/check
|
||||
}
|
||||
@@ -106,6 +116,9 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
# Inject Njalla API token for DNS-01 challenge
|
||||
systemd.services.caddy.serviceConfig.EnvironmentFile = config.age.secrets.njalla-api-token-env.path;
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d ${config.services.caddy.dataDir} 700 ${config.services.caddy.user} ${config.services.caddy.group}"
|
||||
];
|
||||
|
||||
14
services/ddns-updater.nix
Normal file
14
services/ddns-updater.nix
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
services.ddns-updater = {
|
||||
enable = true;
|
||||
environment = {
|
||||
PERIOD = "5m";
|
||||
# ddns-updater reads config from this path at runtime
|
||||
CONFIG_FILEPATH = config.age.secrets.ddns-updater-config.path;
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user