I have domain.me domain. I want to use *.hs.domain.me domain in my home lab and these services should not be publicly accessible.
For this, I have added a NS record to hs.domain.me that points it to a VPN/internal only DNS server and I have configured all the subdomains there.
Now, I want to use Caddy to put TLS in front of all those private apps. I knew http challenge will not work because these domains will not be accessible from outside and I momentarily forgot DNS01 challenge suffers from the same problem. Caddy adds the secret at _acme-challenge.hs.domain.me but LE/ZeroSSL can not find this secret.
2. Error messages and/or full log output:
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.
A pre-start script which removes the NS record from hs.domain.me. This makes _acme-challenge.hs.domain.me reachable from public.
Start caddy, wait until it has received TLS certificates.
Add the NS record again.
I initially thought of doing this with bash scripts but that’s problematic because caddy will try to renew certificate without restarting and without providing any external signals I can use in my bash script.
What’s a good way to solve this problem ? I guess another option is to fork dns-cloudflare and update it to do this ? It already uses the cloudflare token so I guess it should be as easy as adding two more API calls to add/remove NS records.
Please suggest if there is any other idea I have missed here. Thank you!
And here is what the scripts look like. They can almost definitely be cleaned up a little but it works and I am probably not going to bother with this again. (If I had to, I’ll rewrite it in go then do this again)