Caddy v2

For about 10 years I’m running Nginx as my webserver (also for this blog). That’s why I wanted to look for something new, not because I’m not satisfied with Nginx, but because I just wanted to try another webserver with the hope that there might be something better out there.

It came handy that Caddy v2 was released. At that time I already wanted to test the first version, but I didn’t have the chance. Therefore I decided to use Caddy v2 and have been running it for 3 months. And I must say I like it.

What is different about Caddy?

  • Live config API (Seamlessly update your server’s config without downtime using elegant and intuitive REST endpoints)
  • Secure by Default (Caddy is the only web server that uses HTTPS by default)
    • Auto-renew certificates (with Let’s encrypt)
    • It also works with localhost (https)
  • HTTP/2 out of the box, and HTTP/3 by enabling
  • Reverse Proxy/Load balancing
  • No Dependencies (Because Caddy is is written in Go, its binaries are entirely self-contained and run on every platform, including containers without libc)
  • Modular Stack (Take back control over your compute edge. Caddy can be extended with everything you need using plugins)

Check more features on the caddy website.

How do the Caddyfile (config) looks like?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
experimental_http3
}

rmsol.de {
root * /var/www/rmsol.de
encode gzip
header Cache-Control max=age=3600
file_server
}

imagestack.de {
root * /var/www/imagestack.de
file_server
php_fastcgi unix//var/run/php/php7.0-fpm.sock
}

It is much cleaner than Nginx.
PS: you can migrate your Nginx config file to Caddy over config adapters

HTTP 3 support

I also enabled HTTP 3, it is still experimental (not just in Caddy, but in general).
Your browser need also to support it.

  • It can be enabled in Firefox (from version 72) via the network.http.http3.enabled pref in about:config.
  • It can be enabled in Chrome (from version 79) via the –enable-quic & –quic-version=h3-23 command line arguments.