Connect servers and operator devices across different networks using WireGuard, encrypted peer-to-peer communication (100.64.0.0/10), and built-in private service discovery (MagicDNS).
Zero-Config Peer-to-Peer WireGuard Overlay
On first startup, each flarelensd daemon generates an asymmetric Curve25519 keypair locally—the private key is stored 0600 on the host and never leaves the machine—and receives a deterministic CGNAT address in 100.64.0.0/10.
The Control Plane distributes peer public keys and endpoints inside the 15-second heartbeat envelope so nodes form direct ChaCha20-Poly1305 UDP tunnels:
- Zero Public Database Ports: Keep PostgreSQL (
5432) and Redis (6379) completely unexposed on public interfaces; bind them strictly to private interfaces and the WireGuard mesh. - Overlay Service Router (
<overlay_ip>:<mesh_port>): Deterministic private listeners forward mesh traffic with zero-copyio.Copyround-robin across healthy local Blue/Green slots and remote peers. - Cross-Node Ingress Load Balancing: Edge Traefik instances automatically balance HTTP requests across healthy container replicas on peer nodes via
remote_upstreams.
Split-Horizon MagicDNS (<service>.<env>.mesh)
flarelensd embeds a dual-stack UDP + TCP DNS server bound strictly to <overlay_ip>:53 (avoiding conflicts with host systemd-resolved on 127.0.0.53:53) and wires it into managed containers via Docker HostConfig.DNS:
DATABASE_URL=postgres://app:secret@postgres.prod.mesh:5432/core?sslmode=require
REDIS_URL=redis://cache.prod.mesh:6379/0
BILLING_INTERNAL_URL=http://billing-api.prod.mesh:8080TTL = 5sRound-Robin Failover: Queries for<service>.<env>.meshreturn lock-free round-robin A-records of healthy replicas with a 5-second TTL and RFC 4074NODATAonTypeAAAA—so cross-host failovers propagate within seconds.- Strict Environment Isolation:
uatandprodDNS zones remain isolated (postgres.uat.meshvspostgres.prod.mesh), and single-label misses return instant in-memoryNXDOMAINso internal names never leak upstream. ExtraHostsShadowing Guard: When<overlay_ip>:53is active, static100.64.0.0/10entries are stripped from/etc/hostsso Linuxfiles dnslookup order never shadows liveTTL 5sfailover, while retaining/etc/hostsfallback on non-WireGuard hosts.
Operator Workstation Access
Join the private mesh temporarily from macOS or Linux workstations without SSH bastions or per-seat VPN SaaS:
# First-time enrollment via browser SSO (Cloudflare Access):
sudo flarelensd login --control https://ops.example.com
# Connect directly to private mesh services:
psql postgres://readonly@postgres.uat.mesh:5432/app
# Instant zero-browser reconnect after laptop sleep or WSL2 reboot (<200ms):
sudo flarelensd up
# Disconnect interface temporarily (keeps keys) or log out & revoke session:
sudo flarelensd down
sudo flarelensd logoutPublic HTTPS Localhost Funnel (flarelensd http)
Expose a local development server (localhost:3000, localhost:8080, Vite, Next.js, or webhook receiver) on a temporary public HTTPS URL—like ngrok or Tailscale Funnel, at $0/mo with zero third-party tunnel SaaS:
# 1. Authenticate onto the mesh once (if not already connected)
sudo flarelensd login --control https://ops.example.com
# 2. Open a public HTTPS tunnel -> http://127.0.0.1:3000
flarelensd http 3000 --subdomain stripe-webhooks
# 3. Enable the local Webhook Request Inspector & 1-click replay UI on http://127.0.0.1:4040
flarelensd http 3000 --subdomain stripe-webhooks --inspect
# Optional: protect public preview with HTTP Basic Auth
flarelensd http 5173 --subdomain ui-preview --auth demo:s3cr3t
# Optional: explicitly choose Direct Cloudflare Edge QUIC (`edge`) vs Sovereign WireGuard + Traefik (`mesh`)
flarelensd http 5173 --subdomain ui-preview --mode edge- Dual-Mode Transport (
--mode auto|edge|mesh): WhenCF_EDGE_API_TOKENandCF_ACCOUNT_IDare configured on the Control Plane,flarelensd httpautomatically connects directly from your workstation to the nearest local Cloudflare Edge POP over QUIC (~5–15 mslocal latency, zero server bandwidth, and zero Worker request quotas); otherwise it transparently routes over the private WireGuard mesh to your gateway node’s Traefik edge. - Zero LAN Exposure:
flarelensd httpbinds its local HTTP + WebSocket reverse proxy strictly on loopback (127.0.0.1) or your workstation’s100.64.0.xWireGuard interface—never0.0.0.0—and rewritesHost: localhost:<port>automatically while settingX-Forwarded-HostandX-Forwarded-Proto: https. - Local Webhook Inspector & 1-Click Replay (
--inspect): Pass--inspect(or--inspect-addr 127.0.0.1:4040) to launch a zero-dependency local inspector UI onhttp://127.0.0.1:4040with live SSE streaming, automatic Stripe / Paystack / GitHub / Svix event detection, byte-exact HMAC-preserving 1-click webhook replay (even if your local server was down with502or returned500on initial delivery), editable payload replay, and reproduciblecurlexport. - Keyless Ed25519 Ownership & Collision Guards: Requests are signed with your workstation’s
~/.flarelens/id_ed25519key (flarelens-mesh-tunnel:<action>:<wg_pub>:<ts>). Active Fleet service domains and existing permanent DNS records cannot be overwritten (409 Conflict). - Automatic Cleanup: Pressing
Ctrl+Cimmediately deletes the D1 lease and removes the temporary Cloudflare Edge CNAME/tunnel (or gatewayfunnel-<id>.yamlTraefik route); if a laptop disconnects abruptly, the 1-minute Control Plane cron reaps expired leases automatically.