How To: Build Caddy 2.0 from scratch with Cloudflare DNS Provider module for automatic TLS when you have enabled “Always Use HTTPS” in Cloudflare

I’ve seen this being asked and answered a few times, but there are bits and pieces all over the place. I have taken the time to repeat and document the entire process starting from a vanilla Ubuntu install to building the binary from scratch to getting Caddy 2 doing its automatic HTTPS magic, serving out a website in this article:

Get Caddy 2.0 now with Cloudflare DNS Provider module for automatic TLS

Note that this module is only useful if you have enabled Cloudflare’s “Always Use HTTPS” option, where Cloudflare’s MITM would blindly redirect all HTTP requests, causing Caddy’s HTTP challenge to fail. If you do not enable this option in Cloudflare, you do not need this DNS module at all, as the stock version of Caddy would automatically activate your SSL certificate just fine.

Hopefully, someone would find it useful at some point.


Thanks @Jitdor for sharing. My next stop was to learn how to build custom Caddy v2 binaries and you just made my learning adventures much easier :grinning: :+1:

 diff -u <(./caddy list-modules) <(./caddy-gcc9 list-modules)  
--- /dev/fd/63  2020-05-10 13:57:42.972146109 +0000
+++ /dev/fd/62  2020-05-10 13:57:42.972146109 +0000
@@ -14,6 +14,7 @@

Thanks for writing and sharing, @Jitdor!

(I moved this thread into the Showcase category since it just links to an external article. We like the wiki topics to have the actual content in the post.)


This topic was automatically closed after 14 days. New replies are no longer allowed.