Server: replace traefik with caddy

This commit is contained in:
Toast 2024-07-18 00:45:00 +02:00
parent 5001e70c14
commit 863840b2b1
6 changed files with 33 additions and 77 deletions

11
roles/server/caddy.nix Normal file
View file

@ -0,0 +1,11 @@
{...}: {
services.caddy = {
enable = true;
extraConfig = ''
(tailscale) {
tls internal
bind 100.73.96.48
}
'';
};
}

View file

@ -11,7 +11,7 @@
./ddclient.nix
./beep.nix
./tailscale.nix
./traefik.nix
./caddy.nix
./dns.nix
./rust_motd.nix
];

View file

@ -47,20 +47,12 @@ in {
# Add a cname for forgejo
services.dnsmasq.settings.cname = ["git.everest.tailscale,everest"];
# Set up traefik as the reverse proxy for Forgejo
services.traefik = {
dynamicConfigOptions = {
http = {
routers = {
forgejo-subpath = {
rule = "Host(`git.everest.tailscale`)";
service = "forgejo";
};
};
services.forgejo.loadBalancer.servers = [
{url = "http://localhost:${toString config.services.forgejo.settings.server.HTTP_PORT}";}
];
};
};
# Set up caddy as the reverse proxy for Forgejo
services.caddy.virtualHosts.forgejo = {
hostName = "git.everest.tailscale";
extraConfig = ''
import tailscale
reverse_proxy localhost:${toString config.services.forgejo.settings.server.HTTP_PORT}
'';
};
}

View file

@ -36,20 +36,12 @@
# Add a cname for syncthing
services.dnsmasq.settings.cname = ["sync.everest.tailscale,everest"];
# Set up traefik as the reverse proxy for syncthing
services.traefik = {
dynamicConfigOptions = {
http = {
routers = {
syncthing-subdomain = {
rule = "Host(`sync.everest.tailscale`)";
service = "syncthing";
};
};
services.syncthing.loadBalancer.servers = [
{url = "http://localhost:8384";}
];
};
};
# Set up caddy as the reverse proxy for syncthing
services.caddy.virtualHosts.syncthing = {
hostName = "sync.everest.tailscale";
extraConfig = ''
import tailscale
reverse_proxy localhost:8384
'';
};
}

View file

@ -1,31 +0,0 @@
{...}: {
specialisation.traefikEnableWebUI.configuration.services.traefik = {
staticConfigOptions = {
api = {
# Enable the web ui
insecure = true;
dashboard = true;
};
};
};
services.traefik = {
enable = true;
staticConfigOptions = {
entryPoints = {
http = {address = "100.73.96.48:80";};
};
};
};
systemd = {
units.tailscaled.requiredBy = ["traefik.service"];
# We have somewhat frequent power outages, and our ISP router takes
# ages to boot up. If I don't add a delay, traefik tries to bind to
# the tailscale interface before it's ready, making it crash too much
# in too little time
services.traefik.serviceConfig.RestartSec = 120;
};
networking.firewall.allowedTCPPorts = [80 8080];
}

View file

@ -40,20 +40,12 @@ in {
# Add a cname for transmission
services.dnsmasq.settings.cname = ["transmission.everest.tailscale,everest"];
# Set up traefik as the reverse proxy for transmission
services.traefik = {
dynamicConfigOptions = {
http = {
routers = {
transmission-subdomain = {
rule = "Host(`transmission.everest.tailscale`)";
service = "transmission";
};
};
services.transmission.loadBalancer.servers = [
{url = "http://localhost:${toString config.services.transmission.settings.rpc-port}";}
];
};
};
# Set up caddy as the reverse proxy for transmission
services.caddy.virtualHosts.transmission = {
hostName = "transmission.everest.tailscale";
extraConfig = ''
import tailscale
reverse_proxy localhost:${toString config.services.transmission.settings.rpc-port}
'';
};
}