Hosting local https with trusted cert from Cloudflare with Caddy¶
Caddy and tools needed for xcaddy¶
Install caddy from the docs: caddyserver.com/docs/install
Install Go¶
I did this just using snaps
Install git as well
Install xcaddy per the github instructions: https://github.com/caddyserver/xcaddy
Now you should be able to build Caddy with the cloudflare dns plugin:
Stop caddy
Replace the existing caddy binary
Find where the existing Caddy binary is installed:
This typically returns /usr/bin/caddy or /usr/local/bin/caddy.
Now, replace the existing binary with the one you just built:
Verify the new binary is in place
You should see dns.providers.cloudflare
listed.
Restart caddy
If you encounter issues, check the logs:
to dry run the Caddyfile:
Open up your Caddfile located at /etc/caddy/Caddyfile
Add a block for the domain you want to handle on the local network
immich.local.yourdomain.com {
tls {
dns cloudflare {env.CLOUDFLARE_API_TOKEN}
}
reverse_proxy 127.0.0.1:2283
}
You'll need a Cloudflare API Token to allow Caddy to manage your DNS.
Go to Cloudflare Dashboard → API Tokens. Click Create Token → Custom Token. Set permissions: Zone → DNS → Edit Zone Resources → Include Specific Zone → Select Your Domain Click Create Token and copy it.
Now create an A record in your cloudflare dns with a wildcard, i.e. *.local
and send it to the local IP of your server.
You now have a web server with domains that can only be used on the local network.