I’ve been running a small server in my appartment for a while. One of the things I’ve been using it for is as a remote development host, meaning all my personal project are stored and hosted on it. I also host a few apps like Home assistant and Grafana.
How to ๐
When starting to host sites on my devbox, an issue I ran into was not being able to serve projects over HTTPS.
Since the server can’t be reached over HTTPS publicly, Caddy doesn’t have a way to generate certificates and get them verified.
To overcome this we can use the Cloudflare API as a sort of intermediary, so we can reply to challenges, when caddy wants to issue a certificate. Luckily Caddy has modules to make this setup extremely easy.
- Download the Caddy binary with Cloudflare installed
- Overwrite Caddy in /usr/bin
- Remember to chown as root and chmod +x
- Create a
Cloudflare API token
- It only needs permission to edit DNS
- Update your Caddyfile with cloudflare config
domain.name { tls { dns cloudflare <API_TOKEN> } ... }
- Restart Caddy
Caddy can now generate valid certificates for your non-public sites, enabling you to serve them over HTTPS.
Resources: ๐
- This wiki page describes the Caddy + Cloudflare integration well.