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 = {
|
||||
enable = true;
|
||||
tunnels.homelab = {
|
||||
credentialsFile = "/mnt/data/cloudflared/homelab.json";
|
||||
certificateFile = "/mnt/data/cloudflared/cert.pem";
|
||||
default = "http_status:404";
|
||||
ingress = {
|
||||
"git.${homelab.domain}" = "http://localhost:3000";
|
||||
"auth.${homelab.domain}" = "http://localhost:1411";
|
||||
"dash.${homelab.domain}" = "http://localhost:5070";
|
||||
"gallery.${homelab.domain}" = "http://localhost:2284";
|
||||
ingress = routes;
|
||||
};
|
||||
|
||||
systemd.services.cloudflared-dns-route = {
|
||||
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