Score:0

Two domains server_names but separate SSL certificates in NGINX?

ng flag
Max

My NGINX config has a single server defined, and in server-name I have both my domains listed. However, I'd like to keep their SSL certificates separate if possible. I tried using certbot twice, once for each domain, but it seems certbot changes the server's ssl_certificate path in the NGNIX config to match the second domain and overwrites the first domain. Is there a way around this?

Thanks!

in flag
Use separate server blocks.
Max avatar
ng flag
Max
I'd like to have everything in the same server block as possible, as they are supposed to be clones of each other in their functionality. If I were to separate server blocks, is there a way to 'redirect' from one server block to the other without actually doing a redirect that the browser has to follow?
John Hanley avatar
cn flag
Unless you have a solid technical reason, why do this? There are advantages to have multiple names in one certificate for closely related domain+subdomains. If you really want separate certificates, you must declare separate servers (server blocks). To the browser, two different domain names are different resources/locations. To go from one to the other in the browser requires a redirect. If you are concerned with Google ranking, do not have two URIs with the same content (cloned websites). This means redirecting from the slave content to the master content (e.g example.com -> www.example.com)
Jens Bradler avatar
jp flag
You can have two different server blocks including the same configuration by using config file includes via "include conf/my-server-block.conf;". This way you can have different certificates for your different servers, but you are able to maintain your server's configuration in one file.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.