Caddy recently changed their pricing and licensing, which ultimately lead to quite a few upset users. For example, I recently received an email from a student of my course (Web Development with Go) who asked if I was going to redo my deployment videos and remove Caddy from them because he would never be using Caddy again after the license change.
While I don’t want to get into a debate about the changes made by Caddy, what I do want to say is that the source code is still free, open source software licensed under the Apache 2.0 license - https://github.com/mholt/caddy/blob/master/LICENSE.txt
What that means is that all of the changes - the EULA attached to the binaries, and the
Caddy-Sponsors header required for the personal license, and the non-commercial aspect of the license - all only apply if you download a binary provided by the Caddy team.
If you don’t agree with those changes, or maybe you simply can’t afford the pricing, an alternative option is to simply build Caddy from source and use it that way. In this post I am going to walk you through how to do that because it is incredibly simple to do. In fact, it is so simple you can see it done in about 30s in the sped up gif below.
I hope that after seeing how easy it is that many of you will take a step back before throwing rocks and instead spend a few minutes evaluating whether this change actually has a massive negative impact on you. Matt and everyone else involved with Caddy could have changed the license of the source code for Caddy, but they didn’t. It is still open source, and despite not agreeing with all the other changes I do respect them for writing a great piece of software and keeping it open source.
Caddy requires Go 1.8+, so you may need to update if you have an older version.
To start, we need to install Go. If you haven’t done so already, I suggest checking out the official docs here: https://golang.org/doc/install
Alternatively, you could likely do this with Docker but I won’t cover that here.
Next we are going to get the source for caddy and remove the
Caddy-Sponsors header that many people were against. We will need to grab both
mholt/caddy as well as the
caddyserver/builds package, and I suggest using the
-u flag to ensure you have an updated version.
cd $GOPATH/src go get -u github.com/mholt/caddy go get -u github.com/caddyserver/builds
Next we are going to remove the sponsors header.
Caddy reverted the
Caddy-Sponsors header change in PR#1866, so this likely isn’t necessary anymore.
# Use your editor of choice cd $GOPATH/src/github.com/mholt/caddy atom caddyhttp/httpserver/server.go
Find the lines that read:
sponsors := "Minio, Uptime Robot, and Sourcegraph" w.Header().Set("Caddy-Sponsors", "This free web server is made possible by its sponsors: "+sponsors)
At the time of this writing they could be found at lines 346 and 347.
Comment those both out. As far as I can tell these are the only lines you need to change to remove the header. You can also remove th “Server” header if you wish - it is just above these lines of code.
Save your source code then head back to the terminal. We are now ready to build caddy.
cd $GOPATH/src/github.com/mholt/caddy/caddy # For most linux distros: go run build.go -goos=linux -goarch=amd64 # For most mac OS computers: go run build.go -goos=darwin
You can read a bit more about the GOOS, GOARCH, and the GOARM options here at https://golang.org/doc/install/source#environment. All three of these are supported as flags to the
After building you should have a binary in your current directory named
caddy. Congrats, you have successfully built Caddy from scratch!
If you enjoyed this article, please consider joining my mailing list.
I will send you roughly one email every week letting you know about new articles (like this one) or screencasts (ex) that I am working on or have published recently. No spam. No selling your emails. Nothing shady - I’ll treat your inbox like it was my own.
As a special thank you for joining, I’ll also send you both screencast and ebook samples from my course, Web Development with Go.
Sign up for my mailing list and I'll send you a FREE sample from my course - Web Development with Go. The sample includes three chapters from the book, and over 2.5 hours of screencasts.
You will also receive notifications when I release new articles, along with other freebies that I only share with my mailing list.
Jon Calhoun is a full stack web developer who also teaches about Go, web development, algorithms, and anything programming related. He also consults for other companies who have development needs. (If you need some development work done, get in touch!)
Jon is a co-founder of EasyPost, a shipping API that many fortune 500 companies use to power their shipping infrastructure, and prior to founding EasyPost he worked at google as a software engineer.
Spread the word
Did you find this page helpful? Let others know about it!
Sharing helps me continue to create both free and premium Go resources.
Want to discuss the article?
©2018 Jonathan Calhoun. All rights reserved.