I often encounter following problem.
I have an nginx server serving two hostnames via https on the same IP and the same port. Each host name has it's own cert.
What I am doing so far is to have two configurations:
server {
listen 443 ssl;
server_name www.example1.com;
ssl_certificate www.example1.com.crt;
ssl_certificate_key www.example1.com.key;
ssl_protocols ...;
ssl_ciphers ...;
...
}
and
server {
listen 443 ssl;
server_name www.example2.com;
ssl_certificate www.example2.com.crt;
ssl_certificate_key www.example2.com.key;
ssl_protocols ...;
ssl_ciphers ...;
...
}
Is there any trick to have this done in only one server block?
The reason I'm asking is, that both servers share apart of the name and the cert exactly the same config.
What I do so far is:
server {
listen 443 ssl;
server_name www.example1.com;
ssl_certificate www.example1.com.crt;
ssl_certificate_key www.example1.com.key;
include /etc/nginx/common_config/example1_and_2/*;
}
server {
listen 443 ssl;
server_name www.example2.com;
ssl_certificate www.example2.com.crt;
ssl_certificate_key www.example2.com.key;
include /etc/nginx/common_config/example1_and_2/*;
}
Can this be improved is there some standard recommendation? If this is at good as it gets, is there at least a recommendation for the path to such common config giles?