all: cleanup caddy

This commit is contained in:
Adithya 2024-10-27 23:09:50 +05:30
parent 50032d4383
commit 486eb71240
Signed by: adtya
GPG key ID: B8857BFBA2C47B9C
22 changed files with 64 additions and 54 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -7,7 +7,7 @@ in
services = {
caddy.virtualHosts."${domainName}" = {
serverAliases = [ "www.${domainName}" ];
logFormat = logFormat domainName;
inherit logFormat;
extraConfig = ''
handle {
root * ${inputs.adtyaxyz.packages.${pkgs.system}.default}/share/web

View file

@ -7,7 +7,7 @@ in
services = {
caddy.virtualHosts = {
"${domainName}" = {
logFormat = logFormat domainName;
inherit logFormat;
extraConfig = ''
redir https://keyoxide.org/hkp/51E4F5AB1B82BE45B4229CC243A5E25AA5A27849
'';

View file

@ -6,7 +6,7 @@ in
{
services = {
caddy.virtualHosts."${domainName}" = {
logFormat = logFormat domainName;
inherit logFormat;
extraConfig = ''
handle {
root * ${inputs.wiki.packages.${pkgs.system}.default}/share/web

View file

@ -1,6 +1,6 @@
_:
let
inherit (import ../../shared/caddy-helpers.nix) tlsDNSChallenge;
inherit (import ../../shared/caddy-helpers.nix) logFormat tlsAcmeDnsChallenge;
in
{
imports = [
@ -14,32 +14,37 @@ in
services.caddy = {
virtualHosts = {
"gateway.labs.adtya.xyz" = {
inherit logFormat;
extraConfig = ''
${tlsDNSChallenge}
${tlsAcmeDnsChallenge}
reverse_proxy 192.168.0.1:80
'';
};
"ap1.labs.adtya.xyz" = {
inherit logFormat;
extraConfig = ''
${tlsDNSChallenge}
${tlsAcmeDnsChallenge}
reverse_proxy 192.168.1.1:80
'';
};
"ap2.labs.adtya.xyz" = {
inherit logFormat;
extraConfig = ''
${tlsDNSChallenge}
${tlsAcmeDnsChallenge}
reverse_proxy 192.168.1.2:80
'';
};
"switch.labs.adtya.xyz" = {
inherit logFormat;
extraConfig = ''
${tlsDNSChallenge}
${tlsAcmeDnsChallenge}
reverse_proxy 192.168.1.3:80
'';
};
"frp.labs.adtya.xyz" = {
inherit logFormat;
extraConfig = ''
${tlsDNSChallenge}
${tlsAcmeDnsChallenge}
reverse_proxy 10.10.10.1:7500
'';
};

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,11 +1,11 @@
{
logFormat = fileName: ''
logFormat = ''
output stderr
format json
level DEBUG
level INFO
'';
tlsDNSChallenge = ''
tlsAcmeDnsChallenge = ''
tls {
dns digitalocean {env.DO_API_TOKEN}
}

View file

@ -23,7 +23,7 @@ in
metrics
}
'';
logFormat = logFormat "caddy_main";
inherit logFormat;
};
systemd.services.caddy.serviceConfig.EnvironmentFile = config.sops.secrets."caddy/env_file".path;
networking.firewall.allowedTCPPorts = [ 80 443 ];

View file

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

View file

@ -6,7 +6,7 @@ in
{
services = {
caddy.virtualHosts."${domainName}" = {
logFormat = logFormat domainName;
inherit logFormat;
extraConfig = ''
handle /.well-known/matrix/server {
header Content-Type application/json

View file

@ -15,7 +15,7 @@ in
};
services = {
caddy.virtualHosts."${domainName}" = {
logFormat = logFormat domainName;
inherit logFormat;
extraConfig = ''
reverse_proxy /client/* 127.0.0.1:8009
# reverse_proxy /_matrix/client/unstable/org.matrix.msc3575/sync 127.0.0.1:8009

View file

@ -7,7 +7,7 @@ in
{
services = {
caddy.virtualHosts."${domainName}" = {
logFormat = logFormat domainName;
inherit logFormat;
extraConfig = ''
reverse_proxy ${cfg.settings.server.HTTP_ADDR}:${toString cfg.settings.server.HTTP_PORT}
'';

View file

@ -1,20 +1,21 @@
{ lib, config, ... }:
let
inherit (import ../../../shared/caddy-helpers.nix) logFormat;
inherit (import ../../../shared/caddy-helpers.nix) logFormat tlsAcmeDnsChallenge;
domainName = "ntfy.acomputer.lol";
in
{
services = {
caddy.virtualHosts = {
"${domainName}" = {
logFormat = logFormat domainName;
inherit logFormat;
extraConfig = ''
reverse_proxy ${config.services.ntfy-sh.settings.listen-http}
'';
};
"${config.networking.hostName}.labs.adtya.xyz" = {
logFormat = logFormat domainName;
inherit logFormat;
extraConfig = ''
${tlsAcmeDnsChallenge}
handle /ntfy-metrics {
uri replace /ntfy-metrics /metrics
reverse_proxy ${config.services.ntfy-sh.settings.metrics-listen-http}