tunnel config
This commit is contained in:
parent
35e59b9e50
commit
fc66316343
1 changed files with 26 additions and 6 deletions
|
|
@ -1,16 +1,36 @@
|
||||||
{ homelab, ... }: {
|
{ pkgs, lib, homelab, ... }: let
|
||||||
|
routes = {
|
||||||
|
"git.${homelab.domain}" = "http://localhost:3000";
|
||||||
|
"auth.${homelab.domain}" = "http://localhost:1411";
|
||||||
|
"dash.${homelab.domain}" = "http://localhost:5070";
|
||||||
|
"gallery.${homelab.domain}" = "http://localhost:2284";
|
||||||
|
};
|
||||||
|
in {
|
||||||
services.cloudflared = {
|
services.cloudflared = {
|
||||||
enable = true;
|
enable = true;
|
||||||
tunnels.homelab = {
|
tunnels.homelab = {
|
||||||
credentialsFile = "/mnt/data/cloudflared/homelab.json";
|
credentialsFile = "/mnt/data/cloudflared/homelab.json";
|
||||||
certificateFile = "/mnt/data/cloudflared/cert.pem";
|
certificateFile = "/mnt/data/cloudflared/cert.pem";
|
||||||
default = "http_status:404";
|
default = "http_status:404";
|
||||||
ingress = {
|
ingress = routes;
|
||||||
"git.${homelab.domain}" = "http://localhost:3000";
|
};
|
||||||
"auth.${homelab.domain}" = "http://localhost:1411";
|
|
||||||
"dash.${homelab.domain}" = "http://localhost:5070";
|
systemd.services.cloudflared-dns-route = {
|
||||||
"gallery.${homelab.domain}" = "http://localhost:2284";
|
description = "Sync Cloudflare Tunnel DNS routes";
|
||||||
|
after = [ "network-online.target" ];
|
||||||
|
wants = [ "network-online.target" ];
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
RemainAfterExit = true;
|
||||||
|
Type = "oneshot";
|
||||||
|
User = "root";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
script = lib.concatMapStringsSep "\n" (domain: ''
|
||||||
|
echo "Ensuring DNS route for ${domain}..."
|
||||||
|
${pkgs.cloudflared}/bin/cloudflared tunnel --origincert /mnt/data/cloudflared/cert.pem route dns ${homelab.cf-tunnel-id} ${domain} || true
|
||||||
|
'') builtins.attrNames routes;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue