Web / Caddy Server Interview questions
How do you set up a multi-domain reverse proxy with per-host TLS in Caddy?
Because Caddy issues certificates per hostname automatically, running several independent domains through the same instance just means writing several site blocks - each one gets its own certificate and its own routing without extra TLS configuration.
shop.example.com { reverse_proxy localhost:4001 } blog.example.org { reverse_proxy localhost:4002 } status.example.net { reverse_proxy localhost:4003 basic_auth { ops $2a$14$Zkq... } }
Each block's address becomes the certificate's Common Name, so Caddy requests and manages three separate certificates behind the scenes, one per domain, and routes each incoming TLS connection to the right block using the SNI hostname from the handshake before any HTTP-level logic runs. Shared behavior across domains, like common security headers, is usually factored out into a snippet with (name) { ... } and pulled into each block with import name, so the domains stay DRY without needing one giant merged block. There's no practical limit on the number of domains one Caddy instance can serve this way beyond server resources and per-domain CA rate limits.
More Related questions...