Skip to content

Caddy Reverse Proxy

Overview

Component Detail
Software Caddy via OPNsense plugin
TLS Automatic Let's Encrypt via Cloudflare DNS-01 challenge
Domain goozlab.net (Cloudflare DNS)
Services 20+ internal services behind HTTPS
Access Internal only — Trusted, Management and WireGuard networks

Why Caddy?

Caddy replaced Nginx to simplify certificate management. Caddy handles automatic HTTPS with zero manual renewal — it obtains and renews Let's Encrypt certificates automatically using the Cloudflare DNS-01 challenge. The OPNsense Caddy plugin makes it manageable from the firewall GUI.

Configuration

OPNsense WebGUI port change: The default HTTPS port (443) must be free for Caddy. OPNsense's WebGUI was moved to port 8443 under System → Settings → Administration.

DNS-01 challenge: Caddy uses a Cloudflare API token to create TXT records for domain validation. This means no ports need to be open to the internet for certificate issuance — all validation happens via DNS.

Individual domains: Each service gets its own full subdomain (e.g., dash.goozlab.net, ha.goozlab.net). A wildcard certificate was not used due to a known Caddyfile generation bug in the OPNsense plugin.

HTTPS upstream: Services with self-signed certificates (Proxmox, OPNsense, UniFi) use HTTPS upstream with TLS insecure skip verify, so the browser sees a valid Let's Encrypt cert while the backend connection uses the service's own self-signed cert.

Services Behind Caddy

Subdomain Backend Notes
Group Subdomains
------- -----------
Infrastructure fw1, pve1, pve2, pve3, nas, unifi (HTTPS upstream, self-signed)
Monitoring grafana, uptime, dash (Homepage), wazuh, patchmon, tugtainer
Home ha, frigate, zigbee
Apps photos (Immich), vault (Vaultwarden), sync (Syncthing), n8n, ai (Open WebUI), jellyfin, seerr

Each name is a Caddy domain + handler, plus an Unbound host override pointing the name at the firewall. Nothing is published in public DNS — the Cloudflare TXT record only exists for a moment during certificate issuance.

How It Works

Browser ──► Caddy (OPNsense, port 443)
              │
              ├── Valid Let's Encrypt cert (auto-renewed via Cloudflare DNS-01)
              │
              └── Reverse proxy to internal service
                    │
                    ├── HTTP backends: direct proxy
                    └── HTTPS backends: TLS with skip verify (self-signed)

All traffic stays internal — Caddy runs on the OPNsense firewall and proxies to services on the Management VLAN. No ports are exposed to the internet except WireGuard VPN, and an access list (internal_only: Trusted, Management, WireGuard) on every site returns 403 to anything else — including the IoT and Guest networks. Access logging is on for every site.

Setup Steps

  1. Install the Caddy plugin in OPNsense (System → Firmware → Plugins → os-caddy)
  2. Move OPNsense WebGUI to port 8443 (System → Settings → Administration → TCP Port)
  3. Create a Cloudflare API token with Zone:DNS:Edit permissions for your domain
  4. Configure DNS provider in Services → Caddy → General → DNS Provider (Cloudflare + token)
  5. Add domains in Services → Caddy → General → Domains — one entry per subdomain
  6. Add handlers in Services → Caddy → General → Handlers — map each domain to its backend address and port
  7. Add an access list with the networks allowed in, and attach it to every domain
  8. Add an Unbound host override for each name, pointing at the firewall's Management address
  9. Enable Caddy and verify certificates are issued (check the Caddy log for Let's Encrypt activity)

Lessons Learned

  • Individual domains, not wildcard. The OPNsense Caddy plugin has a known bug with wildcard certificate generation in the Caddyfile. Use individual full domains per service instead.
  • HTTPS upstream for self-signed backends. Proxmox, OPNsense, and UniFi all use self-signed certificates. Configure Caddy to use HTTPS upstream with TLS insecure skip verify for these backends.
  • Give new certs a minute. If Unbound is reloading at the moment Caddy asks for a certificate, the first DNS-01 attempt can fail with "could not find the start of authority". Caddy retries on its own.
  • Streaming apps: ntfy is used on its direct IP rather than through Caddy, because its streaming connections didn't play well with the proxy.
  • WebGUI port conflict. Caddy needs port 443. Moving OPNsense to 8443 is the standard solution — update your bookmarks and any monitoring that checks the WebGUI.