avatar of hatsune miku

Migrating from Nginx to Caddy

2024-09-11

I recently made the switch from Nginx to Caddy as my reverse proxy and static file server. My previous Nginx setup required a significant amount of configuration to optimize and set up TLS. I also had to run a separate Certbot container alongside Nginx, which caused its fair share of headaches – especially when it came to renewing certificates. I recall having to trigger a config reload in Nginx to pick up the new certificates, which wasn't immediately obvious. The configuration for all my sites was a whopping 250 lines, with a lot of boilerplate code for each service. To make matters worse, I was using different ports instead of subdomains for each service, which meant forwarding an extra port every time.

In contrast, Caddy has been a breath of fresh air. With subdomains, adding a new service is a breeze – I just need to add three lines of config: the domain name, the reverse proxy destination, and a closing curly bracket. I also need to create a new CNAME entry in Dynv6, my dynamic DNS provider. While Caddy's performance may not be on par with an optimized Nginx instance (as seen in this benchmark), I don't need to handle thousands of requests per second, so it's not a major concern for me.