Caddy instead of nginx for small projects

nginx is a great server, but for a small project its TLS setup and certificate auto-renewal take noticeably more moving parts. Caddy does that out of the box.

Certificates without the fuss

Caddy obtains and renews Let's Encrypt certificates itself. You just name the domain — provided its DNS record points correctly and the validation port is open.

example.com {
    root * /srv/site
    file_server
    encode gzip
    header Strict-Transport-Security "max-age=31536000"
}

This config serves a static site over HTTPS with compression and a security header — and renews the certificate on its own.

A readable config

The Caddyfile format is compact and hard to break by accident: fewer semicolons and nested blocks than a typical nginx configuration. For a small team that means fewer chances to make a mistake.

When nginx after all

If you need fine control over buffers, complex routing or specific modules, nginx is justified. For static sites, simple services and a quick start, Caddy saves an evening of setup and then stays out of the way.

← All notes