Skip to main content

Caddy

Eliminating Config Drift: GitOps Auto-Deploy for Caddy HA with Semaphore

The Problem # My Caddy reverse proxy runs as an HA pair – two nodes behind a keepalived VIP. Every service in the homelab gets its traffic through this pair. The setup works great, except for one recurring failure mode: config drift. The deployment process was manual: edit the Caddy site config in git, SCP it to both nodes, validate, reload. The “both nodes” part is where things break down. It’s easy to deploy to caddy1, test it, see it working, and then forget caddy2 exists. Until keepalived fails over and suddenly half your sites return 502s because the backup node has last week’s config.

Consolidating PAN-OS Certificate Management with Caddy + Semaphore

The Problem # My PAN-OS firewall (GlobalProtect VPN portal at vpn.mareoxlan.com) needs a valid TLS certificate. I had a dedicated LXC (30122) running acme.sh with a Cloudflare DNS-01 challenge to issue a wildcard cert, then a PAN-OS deploy hook to push it to the firewall via the XML API. It worked, but it was a single-purpose VM doing the same job my Caddy reverse proxy already does – Caddy auto-renews *.mareoxlan.com via the same Cloudflare DNS-01 mechanism.

Architecture: Caddy GitOps Auto-Deploy

Overview # After multiple outages caused by configuration drift between two HA Caddy reverse proxy nodes, I built a GitOps pipeline that automatically deploys configs to both nodes whenever changes are pushed to the main branch. Config drift is now impossible by design. The problem: Two Caddy nodes in a keepalived HA pair need identical configs. Forgetting to deploy to the second node after editing a site config caused service outages — twice in the same week.

Architecture: Vaultwarden Traffic Flow & IP Header Strategy

Overview # When running a self-hosted password manager like Vaultwarden, accurate client IP logging is critical for security alerts. The “New Device Login” email should show the actual IP address of whoever just accessed your vault—not your reverse proxy’s internal IP. This becomes tricky when you have multiple traffic paths: external users coming through Cloudflare Tunnel, and internal users coming through your local reverse proxy. Each path uses different mechanisms to communicate the real client IP.

Protecting Vaultwarden Behind Caddy with Cloudflare Proxy

Overview # Your password vault is arguably the most sensitive service in your homelab. Exposing Vaultwarden to the internet requires layered protection. This tutorial shows how to add Cloudflare Proxy (WAF, DDoS protection, bot management) in front of Vaultwarden while preserving real client IP logging. What you’ll achieve: 1 2 3 4 5 6 7 8 9 Client (real IP) ↓ Cloudflare Edge (WAF, DDoS, Bot protection) ↓ CF-Connecting-IP header Your Firewall (geo-blocking, threat intel) ↓ Caddy (extracts real IP, TLS termination) ↓ X-Real-IP header Vaultwarden (rate limiting, 2FA, logs real IP) Prerequisites # Vaultwarden already running behind Caddy reverse proxy Domain managed by Cloudflare (DNS) Caddy with valid TLS certificates (Let’s Encrypt/ACME) Basic understanding of reverse proxies The Problem # When you enable Cloudflare Proxy (orange cloud), traffic flows through Cloudflare’s edge servers before reaching your origin. This provides excellent protection, but introduces two challenges:

Semaphore Caddy Domain Management Playbooks

What Changed # Added three Ansible playbooks to Semaphore for managing Caddy reverse proxy domains: Add Domain: Creates new reverse proxy entry on both HA nodes Remove Domain: Removes domain from both nodes List Domains: Shows all configured domains across the cluster Why # Manual Caddy config edits were error-prone and required SSH to both nodes. Semaphore templates provide a UI for common operations with built-in validation.

Networking

My homelab network is segmented into 5 VLANs with a multi-tier DNS architecture and high-availability reverse proxy. This wiki covers the design decisions and implementation details. Complete Network Topology # ⛶ Click to expand Homelab Network Topology 5 VLANs · PA-440 NGFW · HA DNS · HA Reverse Proxy ☁️ INTERNET 🌐 ISP Gateway 🛡️ Cloudflare CDN + WAF + Access 🔥 SECURITY EDGE 🛡️ PA-440 Next-Gen Firewall App-ID · DNS Proxy · DHCP · NAT · Zone Security ☁️ CF Tunnel Agent Zero-Trust Tunnel 🔀 NETWORK FABRIC 🚪 UniFi Gateway Inter-VLAN Routing 📡 USW-24 Managed 24-Port PoE Switch 📶 U6-LR WiFi 6 AP 📶 U6-Pro WiFi 6 AP TP-Link Switch Authenticated Trunk Trunk Trunk 🔒 VLAN 10 · MANAGEMENT 192.168.10.0/24 💾 NAS-Primary DS920+ · 4-Bay NFS · iSCSI 💾 NAS-Secondary DS719 · 2-Bay Backup Target DNS HIGH AVAILABILITY HA 🟢 DNS-Primary Pi-hole · Pri 200 VIP .110 🟡 DNS-Secondary Pi-hole · Pri 100 keepalived VRRP 🖥️ TinyPilot KVM Remote Console 🖥️ GL KVM IP-KVM Device 🔥 FW Management Out-of-Band Mgmt 📡 Uplink Switch TP-Link Managed ⚙️ VLAN 30 · SERVERS & SERVICES 192.168.30.0/24 PROXMOX VE CLUSTER 📦 Node-2 LVM-thin Mini PC 📦 Node-3 ZFS Primary API 📦 Node-5 LVM-thin Mini PC 📦 Node-6 ZFS Mini PC 💿 PBS Backup Server NFS → NAS REVERSE PROXY HA HA 🔀 Caddy Primary Reverse Proxy VIP .161 🔀 Caddy Backup Hot Standby MONITORING & LOGGING 📊 Graylog SIEM · Log Server 🛡️ Wazuh XDR FIM · Vuln · CIS 📈 Uptime Kuma Status × 2 📉 Prometheus Metrics + Grafana 🔍 Pi.Alert Network Scanner 💨 MySpeed Speed Tracker AUTOMATION & WORKFLOWS ⚡ n8n Workflow Engine 🎯 Semaphore Ansible CI/CD 🐳 Portainer Container Mgmt 📡 UniFi Controller Network Mgmt APPLICATION SERVICES 🔐 Vaultwarden Passwords 🏠 Home Assist. Smart Home 📱 Homarr Dashboard 🔑 Infisical Secrets Mgmt 🌐 NetBox IPAM SECURITY & VPN 🔒 WireGuard VPN Server 🛡️ Panorama FW Mgmt 🔥 VM Firewalls PAN-OS Lab × 5 🤖 AI Assistants Claude · Gilfoyle 40+ LXCs 🧠 VLAN 20 · AI / DEV 192.168.20.0/24 💻 OpenClaw AI Agent MacBook Pro M4 Max · 48GB · Ollama LLM Inference 🔸 VLAN 40 · ISOLATED 172.30.40.0/24 🌐 DNS-40 Standalone Pi-hole 🔒 Isolated Services Restricted Access ❌ No cross-VLAN access 📱 VLAN 50 · IoT 172.30.50.0/24 🌐 DNS-50 Standalone Pi-hole 📱 Smart Devices IoT · Home Auto 🔒 Fully isolated network 🔐 VLAN 254 · FW MGMT 10.254.254.0/24 🔥 PAN-OS Out-of-Band Management Interfaces LEGEND Physical Connection Virtual / Tunnel VIP HA Virtual IP (VRRP) Management Servers Isolated IoT AI / Dev FW Mgmt EXTERNAL ACCESS PATHS ☁️ Cloudflare Tunnel (Zero-Trust): Vaultwarden · WireGuard · TinyPilot Emby · OpenSpeed Test · KASM 🔀 Caddy HA (Internal TLS): *.loc.domain.com wildcard cert All internal services via DNS-01 🔒 Direct (Management only): Proxmox UI · NAS DSM · Pi-hole VLAN Design # VLAN Subnet Purpose Key Services Security Level 10 192.168.10.0/24 Management & Core NAS, DNS HA, KVM devices 🔒 High 30 192.168.30.0/24 Server Network Proxmox, Docker, Apps ⚙️ Medium 40 172.30.40.0/24 Isolated Services Restricted access 🔸 Low 50 172.30.50.0/24 IoT Devices Smart home 📱 Minimal 254 10.254.254.0/24 Firewall Management Out-of-band mgmt 🔐 Critical Design principle: Servers (VLAN 30) can reach management (VLAN 10), but management devices are protected from server-initiated connections. IoT devices are fully isolated—they cannot initiate connections to any other VLAN.