Compose Factory with Real OIDC, Caddy Auto-TLS & Automated Live Smoke Gates
Written by Horizon Services LLC • Fixed-Price Single-Host Production Architecture
The Production Failure Mode
Agentic platforms and internal B2B webapps frequently rely on bypassed local dev tokens during prototyping, then stall or expose unauthenticated internal ports (0.0.0.0:3000/8000) during production cutover when wiring real OIDC callbacks and TLS.
1. Loopback-Fenced Docker Compose Topology
Bind every application, worker, Postgres, and Redis port strictly to 127.0.0.1 in docker-compose.prod.yml so Caddy (:80/:443) is the sole public ingress.
2. Real Authentik OIDC Authorization-Code Flow
Front administrative and multi-tenant routes with Authentik OIDC SSO, stripping spoofed upstream X-Authentik-* / Remote-* headers at the Caddy edge.
3. Fail-Closed Live Smoke Gate
Execute an automated post-deploy Python check verifying HTTPS 200, valid JSON-LD, OIDC redirect status, and zero exposed host ports before marking a release healthy.
Single-Host TCO vs Fragmented Cloud SaaS
| Architecture Choice | Typical Monthly Spend | Operational Ownership |
|---|---|---|
| Fragmented Cloud SaaS Stack | $490–$850/mo (Auth0 B2B + Managed App Runner + Cloud WAF + CI Runners) | Recurring seat/task tax, vendor rate limits, scattered auth |
| Owned Single-Host Blueprint | $22/mo Plain Linux VM (Caddy Auto-TLS + Self-Hosted Authentik + Loopback Compose) | 100% code & data ownership, predictable fixed monthly VM bill |
Frequently Asked Question
Can Authentik OIDC and Caddy run alongside our existing FastAPI/Next.js stack on one host?
Yes. Authentik and Caddy run cleanly alongside FastAPI, Node, and PostgreSQL on an 8–16 GB single Linux host with strict memory limits and encrypted daily Restic backups.