It took a bunch more work than I expected it to, but I did successfully get a second caddy instance running, with DNS challenge using my DNS provider’s API.
Brief walkthrough:
- set up a caddy instance - I used a Proxmox LXC
- Update and install caddy
- Find out that the plugin needed for caddy to do dns challenges means you have to compile your own caddy with go and a command called
xcaddy
- faff around looking for where this is documented
- get caddy built with your needed DNS provider’s DNS API plugin
- create an api key at your dns provider
- set your caddyfile options with the api key and secret
- find out that you have to enable api access to your domain
- wait
- HTTPS works!
So in more detail:
Installing Caddy isn’t too hard. it’s very straightforward with ubuntu/debian relatives.
The concept of having to rebuild caddy with the needed plugin was a little annoying. I thought they’d have an architecture that would use a plugin code without recompiling, but that’s not it. You have to rebuild caddy with your required plugins enabled at build time, OR download a prebuilt version. I couldn’t figure out the download a prebuilt with Porkbun’s API, so I went through the steps of installing Go, Getting the xcaddy software, then building my own version, and then using docs from here Build from source — Caddy Documentation
Its a little janky, but making it through it and having it working now it’s fine. Just new-to-me kind of way of doing things.
The issue with API access to your domain is probably a porkbun thing no big deal, really. The error in the caddy log was fairly straightforward. Porkbun was telling caddy exactly the issue, and so that was easy to fix.
I actually needed to change PiHole’s Custom DNS to use a separate subdomain than my usual public things so that they don’t step on each other. This is a little in the weeds, but,
Say I want to load jellyfin locally: I would need to use the IP:port address, or my public address j.h.domain.dev. I tried setting up j.h.domain.dev for my pihole dns override, but my pc was still grabbing the public CNAME to my router’s DDNS. So I compromised with the subdomain being “i.domain.dev” for internal, and “h.domain.dev” being “home” but from an external perspective…
Perhaps with the dns challenge caddy setup, I could rejigger some things so that I don’t have to use 2 different subdomains and make sure things are all happy, but that’s still a work-in-progress over here.
But in summary, I now have internally-reachable services, with HTTPS and nice DNS names, without any of that traffic leaving my local network, since my firewall knows nothing about the new caddy instance and can’t pass any traffic to it anyway, but local machines have no issue finding it, and can successfully access services proxied by it. Excellent.
Thanks!