Multiple certificates for multiples domains with Nginx

I have several domains on a dedicated server with a public IP.
OS : Ubuntu Server 16.04 with Nginx 1.10
I want to have a Let's Encrypt Certificate for each domain.
cd /opt/letsencrypt
./letsencrypt-auto certonly -a webroot --webroot-path=/var/www/notes -d -d

This first certificate works.
His server block

server {
	listen 80;
	listen [::]:80;
	return 301 https://$server_name$request_uri;
server {
	listen 443 ssl;
	listen [::]:443 ssl;

	ssl on;
        ssl_certificate 	/etc/letsencrypt/live/;
        ssl_certificate_key 	/etc/letsencrypt/live/;

	ssl_dhparam /etc/ssl/certs/dhparam.pem;
	root /var/www/notes;
	index index.php;

It's ok for this site

I do the same things for the second domain
./letsencrypt-auto certonly -a webroot --webroot-path=/var/www/jcsalomon -d -d
It's ok for Let's Encrypt, I have my /etc/letsencrypt/live/ with the *.pem
His server block is the same.
It's ok when I go to this siite
but when I want to come back to my first domain
I have with Firefox : uses an invalid security certificate. The certificate is only valid for the following names:, Error code: SSL_ERROR_BAD_CERT_DOMAIN

and with Google Chrome :

So, what is the problem ?
Can I have multiple certificates for each domain on a single web Server Nginx ?


Your ssl server blocks don’t have server_name set, so Nginx doesn’t know which one to use resulting in one being chosen by default. If you override the cert warning you’ll see that currently is showing the content of when accessed over https.


Oh my God !!!
Thanks a lot cool110 !
Great !

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.