How to use the Caddyfile Generator
- Pick the scenario: reverse proxy to an app (list several upstreams to load-balance), a static site, an SPA or PHP.
- Enter your domain and how
wwwshould be handled; add an email so Let’s Encrypt can reach you about certificates. - Tick compression, security headers, caching, logging, health checks or basic auth.
- Save it as
/etc/caddy/Caddyfile, runcaddy validateand reload Caddy.
Why the Caddyfile is so short
Caddy turns on HTTPS automatically for any site address that is a real domain: it gets and renews the certificate and redirects HTTP to HTTPS on its own. WebSockets and HTTP/2/3 also work out of the box, so a whole reverse proxy can be three lines:
example.com {
reverse_proxy localhost:3000
}
What the options add
| Option | Directive |
|---|---|
| Load balancing | reverse_proxy with several upstreams, lb_policy and optional active health checks |
| SPA | try_files {path} /index.html so client-side routes work on reload |
| Compression | encode zstd gzip |
| Security headers | A header block with X-Content-Type-Options, Referrer-Policy, X-Frame-Options and removing Server |
| Basic auth | basic_auth with a bcrypt hash on the path you choose |
Related: Nginx Config Generator, Apache VirtualHost Generator, Docker Compose Generator.
Also searched as: caddy reverse proxy, caddyfile example, caddy config generator, caddy load balancer, caddy spa config, caddy php config, caddy basic auth.
Tools that pair well with the Caddyfile Generator
- systemd Service Generator — Run your app as a proper Linux service that starts on boot and restarts when it crashes.
- SSL Checker — Verify an HTTPS certificate in seconds — see when it expires, who issued it, which hostnames it covers and whether the chain is trusted.
- YAML Validator — Paste a Docker Compose file, Kubernetes manifest, GitHub Actions workflow or any YAML to pinpoint errors, catch common pitfalls and get a cleanly formatted version.
- Kubernetes YAML Generator — Fill in your app’s name, image and port and get production-ready Kubernetes YAML: a Deployment with probes, resource limits and a hardened security context, plus the Service, Ingress with TLS, ConfigMap, Secret and HorizontalPodAutoscaler you tick — in one file ready for kubectl apply.