all: use ACME DNS challenge only for internal domains

This commit is contained in:
Adithya 2024-10-27 20:50:37 +05:30
parent 31289b53bc
commit 50032d4383
Signed by: adtya
GPG key ID: B8857BFBA2C47B9C
15 changed files with 58 additions and 15 deletions

View file

@ -1,7 +1,12 @@
_: { _:
let
inherit (import ../../../shared/caddy-helpers.nix) tlsDNSChallenge;
in
{
services = { services = {
caddy.virtualHosts."jackett.labs.adtya.xyz" = { caddy.virtualHosts."jackett.labs.adtya.xyz" = {
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 127.0.0.1:9117 reverse_proxy 127.0.0.1:9117
''; '';
}; };

View file

@ -1,6 +1,6 @@
_: _:
let let
inherit (import ../../../shared/caddy-helpers.nix) logFormat; inherit (import ../../../shared/caddy-helpers.nix) logFormat tlsDNSChallenge;
domainName = "watch.acomputer.lol"; domainName = "watch.acomputer.lol";
in in
{ {
@ -10,12 +10,14 @@ in
"jellyfin.local.adtya.xyz" = { "jellyfin.local.adtya.xyz" = {
logFormat = logFormat "jellyfin.local.adtya.xyz"; logFormat = logFormat "jellyfin.local.adtya.xyz";
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 127.0.0.1:8096 reverse_proxy 127.0.0.1:8096
''; '';
}; };
"jellyfin.labs.adtya.xyz" = { "jellyfin.labs.adtya.xyz" = {
logFormat = logFormat "jellyfin.labs.adtya.xyz"; logFormat = logFormat "jellyfin.labs.adtya.xyz";
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 127.0.0.1:8096 reverse_proxy 127.0.0.1:8096
''; '';
}; };

View file

@ -1,7 +1,12 @@
_: { _:
let
inherit (import ../../../shared/caddy-helpers.nix) tlsDNSChallenge;
in
{
services = { services = {
caddy.virtualHosts."radarr.labs.adtya.xyz" = { caddy.virtualHosts."radarr.labs.adtya.xyz" = {
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 127.0.0.1:7878 reverse_proxy 127.0.0.1:7878
''; '';
}; };

View file

@ -1,7 +1,12 @@
_: { _:
let
inherit (import ../../../shared/caddy-helpers.nix) tlsDNSChallenge;
in
{
services = { services = {
caddy.virtualHosts."readarr.labs.adtya.xyz" = { caddy.virtualHosts."readarr.labs.adtya.xyz" = {
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 127.0.0.1:8787 reverse_proxy 127.0.0.1:8787
''; '';
}; };

View file

@ -1,7 +1,12 @@
_: { _:
let
inherit (import ../../../shared/caddy-helpers.nix) tlsDNSChallenge;
in
{
services = { services = {
caddy.virtualHosts."sonarr.labs.adtya.xyz" = { caddy.virtualHosts."sonarr.labs.adtya.xyz" = {
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 127.0.0.1:8989 reverse_proxy 127.0.0.1:8989
''; '';
}; };

View file

@ -1,6 +1,6 @@
{ pkgs, ... }: { pkgs, ... }:
let let
inherit (import ../../../shared/caddy-helpers.nix) logFormat; inherit (import ../../../shared/caddy-helpers.nix) logFormat tlsDNSChallenge;
in in
{ {
services = { services = {
@ -8,6 +8,7 @@ in
virtualHosts."transmission.labs.adtya.xyz" = { virtualHosts."transmission.labs.adtya.xyz" = {
logFormat = logFormat "transmission.labs.adtya.xyz"; logFormat = logFormat "transmission.labs.adtya.xyz";
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 127.0.0.1:9091 reverse_proxy 127.0.0.1:9091
''; '';
}; };

View file

@ -1,4 +1,8 @@
_: { _:
let
inherit (import ../../shared/caddy-helpers.nix) tlsDNSChallenge;
in
{
imports = [ imports = [
./apps ./apps
./btrfs.nix ./btrfs.nix
@ -11,26 +15,31 @@ _: {
virtualHosts = { virtualHosts = {
"gateway.labs.adtya.xyz" = { "gateway.labs.adtya.xyz" = {
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 192.168.0.1:80 reverse_proxy 192.168.0.1:80
''; '';
}; };
"ap1.labs.adtya.xyz" = { "ap1.labs.adtya.xyz" = {
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 192.168.1.1:80 reverse_proxy 192.168.1.1:80
''; '';
}; };
"ap2.labs.adtya.xyz" = { "ap2.labs.adtya.xyz" = {
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 192.168.1.2:80 reverse_proxy 192.168.1.2:80
''; '';
}; };
"switch.labs.adtya.xyz" = { "switch.labs.adtya.xyz" = {
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 192.168.1.3:80 reverse_proxy 192.168.1.3:80
''; '';
}; };
"frp.labs.adtya.xyz" = { "frp.labs.adtya.xyz" = {
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 10.10.10.1:7500 reverse_proxy 10.10.10.1:7500
''; '';
}; };

View file

@ -1,6 +1,6 @@
_: _:
let let
inherit (import ../../../shared/caddy-helpers.nix) logFormat; inherit (import ../../../shared/caddy-helpers.nix) logFormat tlsDNSChallenge;
domainName = "alertmanager.labs.adtya.xyz"; domainName = "alertmanager.labs.adtya.xyz";
in in
{ {
@ -9,6 +9,7 @@ in
virtualHosts."${domainName}" = { virtualHosts."${domainName}" = {
logFormat = logFormat "${domainName}"; logFormat = logFormat "${domainName}";
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 127.0.0.1:9093 reverse_proxy 127.0.0.1:9093
''; '';
}; };

View file

@ -1,6 +1,6 @@
{ pkgs, ... }: { pkgs, ... }:
let let
inherit (import ../../../shared/caddy-helpers.nix) logFormat; inherit (import ../../../shared/caddy-helpers.nix) logFormat tlsDNSChallenge;
domainName = "blocky.labs.adtya.xyz"; domainName = "blocky.labs.adtya.xyz";
in in
{ {
@ -20,6 +20,7 @@ in
virtualHosts."${domainName}" = { virtualHosts."${domainName}" = {
logFormat = logFormat domainName; logFormat = logFormat domainName;
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 127.0.0.1:8080 reverse_proxy 127.0.0.1:8080
''; '';
}; };

View file

@ -1,6 +1,6 @@
_: _:
let let
inherit (import ../../../shared/caddy-helpers.nix) logFormat; inherit (import ../../../shared/caddy-helpers.nix) logFormat tlsDNSChallenge;
domainName = "grafana.labs.adtya.xyz"; domainName = "grafana.labs.adtya.xyz";
in in
{ {
@ -9,6 +9,7 @@ in
virtualHosts."${domainName}" = { virtualHosts."${domainName}" = {
logFormat = logFormat domainName; logFormat = logFormat domainName;
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 127.0.0.1:9091 reverse_proxy 127.0.0.1:9091
''; '';
}; };

View file

@ -1,6 +1,6 @@
_: _:
let let
inherit (import ../../../../shared/caddy-helpers.nix) logFormat; inherit (import ../../../../shared/caddy-helpers.nix) logFormat tlsDNSChallenge;
domainName = "loki.labs.adtya.xyz"; domainName = "loki.labs.adtya.xyz";
in in
{ {
@ -9,6 +9,7 @@ in
virtualHosts."${domainName}" = { virtualHosts."${domainName}" = {
logFormat = logFormat domainName; logFormat = logFormat domainName;
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 127.0.0.1:3100 reverse_proxy 127.0.0.1:3100
''; '';
}; };

View file

@ -1,6 +1,6 @@
_: _:
let let
inherit (import ../../../shared/caddy-helpers.nix) logFormat; inherit (import ../../../shared/caddy-helpers.nix) logFormat tlsDNSChallenge;
domainName = "prometheus.labs.adtya.xyz"; domainName = "prometheus.labs.adtya.xyz";
in in
{ {
@ -9,6 +9,7 @@ in
virtualHosts."${domainName}" = { virtualHosts."${domainName}" = {
logFormat = logFormat domainName; logFormat = logFormat domainName;
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
reverse_proxy 127.0.0.1:9090 reverse_proxy 127.0.0.1:9090
''; '';
}; };

View file

@ -4,4 +4,10 @@
format json format json
level DEBUG level DEBUG
''; '';
tlsDNSChallenge = ''
tls {
dns digitalocean {env.DO_API_TOKEN}
}
'';
} }

View file

@ -17,9 +17,8 @@ in
package = inputs.caddy.packages.${pkgs.system}.caddy; package = inputs.caddy.packages.${pkgs.system}.caddy;
email = "admin@acomputer.lol"; email = "admin@acomputer.lol";
globalConfig = '' globalConfig = ''
acme_dns digitalocean {env.DO_API_TOKEN}
servers { servers {
trusted_proxies static private_ranges 10.10.10.0/24 fd7c:585c:c4ae::0/64 trusted_proxies static private_ranges 10.10.10.0/24
client_ip_headers X-Forwarded-For X-Real-IP client_ip_headers X-Forwarded-For X-Real-IP
metrics metrics
} }

View file

@ -1,6 +1,6 @@
{ lib, config, ... }: { lib, config, ... }:
let let
inherit (import ./caddy-helpers.nix) logFormat; inherit (import ./caddy-helpers.nix) logFormat tlsDNSChallenge;
in in
{ {
services = { services = {
@ -12,6 +12,7 @@ in
virtualHosts."${vHost}" = { virtualHosts."${vHost}" = {
logFormat = logFormat vHost; logFormat = logFormat vHost;
extraConfig = '' extraConfig = ''
${tlsDNSChallenge}
metrics /caddy-metrics metrics /caddy-metrics
handle /metrics { handle /metrics {
reverse_proxy ${config.services.prometheus.exporters.node.listenAddress}:${toString config.services.prometheus.exporters.node.port} reverse_proxy ${config.services.prometheus.exporters.node.listenAddress}:${toString config.services.prometheus.exporters.node.port}