# Multiple certificates for multiples domains with Nginx

**URL:** <https://community.letsencrypt.org/t/multiple-certificates-for-multiples-domains-with-nginx/18869>\
**Category:** Server\
**Created:** [August 11, 2016, 4:13pm UTC](https://community.letsencrypt.org/t/multiple-certificates-for-multiples-domains-with-nginx/18869 "2016-08-11T16:13:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![D6SOFT](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@D6SOFT](https://community.letsencrypt.org/u/D6SOFT)\
**Post date:** [August 11, 2016, 4:13pm UTC](https://community.letsencrypt.org/t/multiple-certificates-for-multiples-domains-with-nginx/18869/1 "2016-08-11T16:13:51Z")

</div>

Hi,  
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 [notespourdemain.com](http://notespourdemain.com) -d [www.notespourdemain.com](http://www.notespourdemain.com)

This first certificate works.  
His server block

```
server {
	listen 80;
	listen [::]:80;
	server_name notespourdemain.com www.notespourdemain.com;
	return 301 https://$server_name$request_uri;
}
server {
	listen 443 ssl;
	listen [::]:443 ssl;

	ssl on;
        ssl_certificate /etc/letsencrypt/live/notespourdemain.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/notespourdemain.com/privkey.pem;

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

```

It's ok for this site [https://notespourdemain.com](https://notespourdemain.com)

I do the same things for the second domain  
./letsencrypt-auto certonly -a webroot --webroot-path=/var/www/jcsalomon -d [jcsalomon.com](http://jcsalomon.com) -d [www.jcsalomon.com](http://www.jcsalomon.com)  
It's ok for Let's Encrypt, I have my /etc/letsencrypt/live/jcsalomon.com/ with the \*.pem  
His server block is the same.  
It's ok when I go to this siite [https://jcsalomon.com](https://jcsalomon.com)  
but when I want to come back to my first domain [https://notespourdemain.com](https://notespourdemain.com)  
I have with Firefox :

> [www.notespourdemain.com](http://www.notespourdemain.com) uses an invalid security certificate. The certificate is only valid for the following names: [jcsalomon.com](http://jcsalomon.com), [www.jcsalomon.com](http://www.jcsalomon.com) Error code: SSL\_ERROR\_BAD\_CERT\_DOMAIN

and with Google Chrome :  
NET::ERR\_CERT\_COMMON\_NAME\_INVALID

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

Regards,  
Pierre

---

<div class="post-metadata">

**Author:** ![cool110](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/cool110/32/8583_2.png) [@cool110](https://community.letsencrypt.org/u/cool110)\
**Post date:** [August 11, 2016, 4:43pm UTC](https://community.letsencrypt.org/t/multiple-certificates-for-multiples-domains-with-nginx/18869/2 "2016-08-11T16:43:48Z")

</div>

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 [notespourdemain.com](http://notespourdemain.com) is showing the content of [jcsalomon.com](http://jcsalomon.com) when accessed over https.

---

<div class="post-metadata">

**Author:** ![D6SOFT](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@D6SOFT](https://community.letsencrypt.org/u/D6SOFT)\
**Post date:** [August 11, 2016, 5:10pm UTC](https://community.letsencrypt.org/t/multiple-certificates-for-multiples-domains-with-nginx/18869/3 "2016-08-11T17:10:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/letsencrypt/original/3X/c/a/ca6c06ea1ea201324bba7048c6841ce60236468d.png) [@system](https://community.letsencrypt.org/u/system)\
**Post date:** [September 10, 2016, 5:10pm UTC](https://community.letsencrypt.org/t/multiple-certificates-for-multiples-domains-with-nginx/18869/4 "2016-09-10T17:10:27Z")

</div>

Closed on September 10, 2016, 5:10pm UTC

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