Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple IPs+domains+SSL certs for one web site

Tags:

nginx

ssl

I would like to have two domains, each with their own SSL cert, each SSL cert has its own IP of course, to point to the same web site on one physical server. The server will have to have two IPs too of course. What is this called? How is this done with nginx? OS is Linux. Thanks!

like image 951
cat pants Avatar asked Mar 20 '12 19:03

cat pants


1 Answers

Create two server entries with different listen and ssl_certificate(_key) directives using the different IP addresses but the same root where your shared web pages are stored. For example:

server {
  listen 1.2.3.4:443;
  server_name first-domain.example;
  root /srv/html/shared_domain_data;

  ssl on;
  ssl_certificate /etc/nginx/ssl/first_domain.pem;
  ssl_certificate_key /etc/nginx/ssl/first_domain_key.pem;
}

server {
  listen 9.8.7.6:443;
  server_name second-domain.example;
  root /srv/html/shared_domain_data;

  ssl on;
  ssl_certificate /etc/nginx/ssl/second_domain.pem;
  ssl_certificate_key /etc/nginx/ssl/second_domain_key.pem;
}

It's called nothing special.

like image 182
Moritz Bunkus Avatar answered Sep 22 '22 12:09

Moritz Bunkus