My Experience of Switching from NGINX to Caddy

Aaron Turner
3 min readAug 19, 2017

--

One of my coworkers recently linked one of those funny/minimal sites recently, https://doesmysiteneedhttps.com/. After reading the article praising the power of https, you can tell it is a slight plug for Caddy, which is a webserver that is https by default. So, what does this mean?

Caddy will manage settings up, and renewing all of your SSL certificates through Let’s Encrypt. This is awesome for me, as I was a heavy NGINX user, Which didn’t have the easiest time getting SSL set up, and from my experience, all the renewal snippets you could find on guides and stack overflow were really hit or miss. So finding out Caddy would do this for me, was a big win!

However, this doesn’t end at just easy SSL, I’ve noticed that Caddy configuration files are not only much shorter than NGINX files, but they are very “git-able”. For instance, for a simple proxy to a node app running on a port (Which is what we are all usually using NGINX for to begin with), would look something like this:

# Home Page / Portfolio site
aaronthedev.com {
gzip
proxy / localhost:8000 {
transparent
}
}

Literally only 7 lines, and you got yourself an http/https webserver running. For a quick explanation, the first line is a comment, and the second is the domain for my main https://aaronthedev.com. The third enforces some opinionated defaults to get gzipping on my text assets. The fourth tells caddy to listen on root (so every path after the base domain of aaronthedev.com), and proxy it to localhost:8000. The fifth line is some opinionated defaults to help the proxy work more smoothly. The sixth and seventh simply close the blocks. If I recall correctly, my previous NGINX conf for all of my home Raspberry Pi network, which runs across three different pis, was approximately 250 lines in total. My current caddy files are about one fourth of that.

Lastly, to wrap up all of this Caddy love, Caddy has a very easy install process, and great plugin support. I found using the command:

curl https://getcaddy.com | bash

To be the easiest, but the Caddy Download website has the full installation instructions, including any optional plugins. Speaking of those plugins, they are great! Caddy has a list of great plugins in their documentation. They range from opinionated defaults like the `gzip` line I mentioned above, or full on file managers!

However, compared to NGINX, Caddy is definitely slower, but it arguably makes up for it in its readability, maintainability, and ease of use! For someone like me, who is running just a few personal sites and servers, Caddy is perfect. And even if I decided to start a new start up company, as Caddy would be production-ready for something like this. However, If I was somewhere bigger, or needed some intensive / scalable web server NGINX will still be king.

Either way, I am glad I found Caddy, and am looking forward to see how it grows, and how I will grow with it!

--

--

Aaron Turner

Skate. Music. Video Games. Code. Developer / Developer Relations at Wasmer. All opinions expressed are my own. Please excuse the spelling, I am a lazy typist.