DevOps
Caddy
Caddy is a web server and reverse proxy written in Go with automatic HTTPS and very simple configuration.
What it is
Caddy was created by Matt Holt and first released in 2015. Its main difference: HTTPS is automatic. Just give a domain name and Caddy gets and renews Let's Encrypt or ZeroSSL certificates itself.
Configuration in a Caddyfile is very short: a few lines give a reverse proxy with TLS. Inside there is a JSON API for dynamic control, HTTP/2 and HTTP/3 support, compression, load balancing and plugins.
It is one static Go binary with no external dependencies. It fits small and medium services, home servers and quick starts.
Use it when
- You want HTTPS without managing certificates manually.
- You need a simple reverse proxy with minimal configuration.
- You host services on your own server or home lab.
Avoid it when
- You need the most battle-tested module ecosystem and community, like nginx's.
- You want dynamic container discovery out of the box: Traefik is handier.
Key concepts
- Automatic HTTPS
- Caddy obtains, stores and renews certificates for the given domains by itself.
- Caddyfile
- A short human-friendly config format that compiles to JSON.
- reverse_proxy
- A directive that forwards requests to a backend and can balance and health check.
- Admin API
- A JSON API for changing configuration on the fly without a restart.
Example
Interview questions
1. How does Caddy make HTTPS automatic?
For domains in the config it runs the ACME challenge with Let's Encrypt or ZeroSSL, stores the certificate and renews it before expiry. You only need open ports 80 and 443 and correct DNS.
2. How does Caddy differ from nginx?
Caddy has automatic HTTPS and a far shorter config, is written in Go with a JSON API. nginx is more mature, has more modules and strong performance under heavy load, but needs more setup.
3. How do you change config without downtime?
Run caddy reload or send a new config to the Admin API. Caddy applies it without dropping existing connections.
Comparisons with this technology
Related technologies
- nginxnginx is a fast web server and reverse proxy that also works as a load balancer and HTTP cache.
- TraefikTraefik is a cloud-native reverse proxy and edge router that discovers services in Docker and Kubernetes and configures routes itself.
- DockerDocker packages an application with its dependencies into a container that runs the same on a laptop, a server and the cloud.
Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).