1

I have multiple ssl sites on one server with nginx, and the virtual hosting works like this:

root /var/www/html/$host;

But in the certificate section, the $host variable doesn't work:

ssl_certificate /etc/nginx/ssl/$host.crt;
ssl_certificate_key /etc/nginx/ssl/$host.key;

How can I solve this?

Gryu
  • 499
  • 1
  • 6
  • 14
Lay András
  • 111
  • 1

1 Answers1

1

I doubt ssl_certificate can be parametrized - it's parsed when nginx is started, so the process must know it's filename to perform OpenSSL initialization process, but in case of parametrized vhosts this is just not possible - server_name isn't known.

You have to create non-parametrized vhost configuration files for SSL, or use wildcard certificates (for example *.foo.bar) and semi-parametrized vhosts, like server_name *.foo.bar;.

drookie
  • 8,625
  • 1
  • 19
  • 29