/ nix / modules / caddy.nix
caddy.nix
 1  # Caddy reverse proxy — local TLS for Bob services
 2  # Routes *.rig.lan to backend Docker services
 3  
 4  { config, pkgs, lib, ... }:
 5  
 6  {
 7    services.caddy = {
 8      enable = true;
 9      globalConfig = ''
10        # Local TLS — Caddy auto-generates self-signed certs for .lan domains
11        local_certs
12      '';
13      virtualHosts = {
14        # ── LLM inference ────────────────────────────────────────────────
15        "llm.rig.lan" = {
16          extraConfig = "reverse_proxy localhost:8000";
17        };
18  
19        # ── Voice services ───────────────────────────────────────────────
20        "stt.rig.lan" = {
21          extraConfig = "reverse_proxy localhost:10300";
22        };
23        "tts.rig.lan" = {
24          extraConfig = "reverse_proxy localhost:10400";
25        };
26  
27        # ── Home automation ──────────────────────────────────────────────
28        "home.rig.lan" = {
29          extraConfig = "reverse_proxy localhost:8123";
30        };
31  
32        # ── Knowledge ────────────────────────────────────────────────────
33        "sparql.rig.lan" = {
34          extraConfig = "reverse_proxy localhost:7878";
35        };
36  
37        # ── Monitoring ───────────────────────────────────────────────────
38        "grafana.rig.lan" = {
39          extraConfig = "reverse_proxy localhost:3000";
40        };
41        "prometheus.rig.lan" = {
42          extraConfig = "reverse_proxy localhost:9090";
43        };
44  
45        # ── Voice client ──────────────────────────────────────────────
46        "voice.rig.lan" = {
47          extraConfig = ''
48            header Cache-Control "no-cache, no-store, must-revalidate"
49            header Pragma "no-cache"
50            header Expires "0"
51            root * /srv/bob/web
52            file_server
53          '';
54        };
55  
56        # ── Voice enrollment ──────────────────────────────────────────
57        "enroll.rig.lan" = {
58          extraConfig = "reverse_proxy localhost:10800";
59        };
60  
61        # ── NATS monitoring ─────────────────────────────────────────────
62        "nats.rig.lan" = {
63          extraConfig = "reverse_proxy localhost:8222";
64        };
65      };
66    };
67  }