Nginx unable to find new certificate

alpinedockernginxssl-certificate

I use Nginx in a Docker container on Alpine. Used Certbot to generate a new certificate named my.domain.com-0004.

Replacing the certificate with either mv or cp resulted in an SSL protocol error and in logs Nginx was unable to see the file:

2024/04/22 08:41:34 [error] 46#46: *109 cannot load certificate "/etc/letsencrypt/live//fullchain.pem": BIO_new_file() failed (SSL: error:80000002:system library::No such file or directory:calling fopen(/etc/letsencrypt/live//fullchain.pem, r) error:10000080:BIO routines::no such file) while SSL handshaking, client: 34.32.209.4, server: 0.0.0.0:443

Replacing the previous certificate, everything started to work again. I've tried restarting the container without success.

Best Answer

If you look at your error message, you'll see "/etc/letsencrypt/live//fullchain.pem" as the name of the file it's trying to load. Your certificate is at /etc/letsencrypt/live/$ssl_server_name/fullchain.pem according to your cert.conf file. Seems fairly obvious to me that the variable $ssl_server_name has not been set and so is returning an empty string... and so it can't find your certificate because there isn't one where it's looking.

Related Topic