I have Caddy working with auto SSL support (Let’s Encrypt) for my external domain without problems.
But I also want to be able to access the server on the local network with its local network name.
When I used Apache (with a paid cert), this worked. The browser just gave me a warning NET::ERR_CERT_COMMON_NAME_INVALID and let me continue to the page.
With Caddy, I get an error ERR_SSL_PROTOCOL_ERROR and the browser does not let me visit the page.
Nothing related to this error in the docker-compose file.
d. My complete Caddy config:
{
order webdav before file_server
order cgi before handle_path
order cgi before respond
}
externaldomain.com:443 {
handle_path /mypath* {
root * /mypath
file_server browse
}
}
Set up a DNS server in your LAN which resolves your domain name to your server’s LAN IP address for devices within your network. That way you can use the same publicly trusted cert for connecting locally, with the same domain name. This is what I recommend.
Set up a separate site block for your internal hostname, and add tls internal in it, which tells Caddy to issue a cert using it’s own local CA. You can then take Caddy’s root CA cert and install it on all your devices in your LAN to establish trust.
Looks like I would have to duplicate everything that is in the external definition also into the new internal definition? Or is there another way to prevent duplicate definitions?
caddy-caddy-1 | {"level":"info","ts":1716106020.9321294,"msg":"warning: \"certutil\" is not available, install \"certutil\" with \"apt install libnss3-tools\" or \"yum install nss-tools\" and try again"}
The internal cert is working despite this warning.
Edit:
One more thing: The internal auto SSL does not work with IP addresses:
This generates an internal cert for the IP address, but browser and curl cannot connect to https://192.168.0.7 because of “tlsv1 alert internal error”.
Is this a bug or expected?
Yeah you can ignore that warning, it’s just Caddy attempting to install the root CA cert in the system’s trust store, but inside a container it doesn’t have any of the software necessary to install. Specifically nss-tools is for installing the cert for Firefox, but obviously you don’t have a Firefox inside the container.
You need to install Caddy’s root CA cert on your host machine so that it trusts connections to Caddy. See the docs: