I
I
imsha2016-11-10 11:38:09
Nginx
imsha, 2016-11-10 11:38:09

How to specify different ssl certificates for domain alias in nginx.conf?

For example, there is an abstract site config.
server {
server_name host1.ru host2.ru;
listen 123.123.123.123;
listen 123.123.123.123 ssl;
ssl on;
ssl_certificate /path/cert.crt;
ssl_certificate_key /path/cert.key;
location / {
....
}
}
The alias has different domains, but the folder on the server is the same, the project code is the same. All rules for all domains are the same.
But the ssl certificate for each domain is different. How to change the config so that a separate certificate is loaded depending on the domain?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
RoverWhite, 2016-11-10
@imsha

To do this, you will have to move Alias ​​to a separate Server section.

server {
server_name host1.ru;
listen 123.123.123.123;
listen 123.123.123.123 ssl;
ssl on;
ssl_certificate /path/cert.crt;
ssl_certificate_key /path/cert.key;

location / {
....
}
}

server {
server_name host2.ru;
listen 123.123.123.123;
listen 123.123.123.123 ssl;
ssl on;
ssl_certificate /path/other_cert.crt;
ssl_certificate_key /path/other_cert.key;

location / {
....
}
}

A
Alexey Ratnikov, 2017-08-22
@MySochi

A similar task, but aliases will be without certificates. Do they also need to be placed in a separate section? Wildcard certificate.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question