See here:
For public domain names:
These are common requirements for any basic production website, not just Caddy. The main difference is to set your DNS records properly before running Caddy so it can provision certificates.
- If your domain’s A/AAAA records point to your server,
- ports 80 and 443 are open externally,
- Caddy can bind to those ports (or those ports are forwarded to Caddy),
- your data directory is writeable and persistent,
- and your domain name appears somewhere relevant in the config,