Correct configuration for SSL over 3 domains on same IP in nginx

Aethereal asked:

I have been working on this for several hours now, to no fruition. Right now I have three domains, for example domain1.com, domain2.org, and domain3.net. These domains are all using the same IP address.

domain1 and domain2 each have an individual SSL certificate from a trusted authority. domain3 has a self-signed certificate, which, while not ideal, is sufficient in this case (not that this should make any difference, I believe).

The problem is, the correct sites are being served when visited by domain, but when accessing via IP address, domain3 is served with domain3’s certificate, and I can’t for the life of me figure out how to get it to use domain1 instead… ideally any request made to the IP would be redirected to domain1.com.

Any help would be appreciated.

My answer:


Add the IP address to the server_name for the server you want to serve it.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.