Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to configure dynamic Virtual host with dynamic SSL configuration in nginx?

Is it possible to configure dynamic SSL certificate path in nginx same as like dynamic virtual host.

ssl_certificate and ssl_certificate_key are not accepting the variables in nginx.

Thanks

like image 289
Sekar Avatar asked Sep 04 '15 05:09

Sekar


People also ask

What method could you use to make dynamic configuration changes with nginx plus?

Using the API for Dynamic Configuration The NGINX Plus REST API supports the following HTTP methods: GET – Display information about an upstream group or individual server in it. POST – Add a server to the upstream group. PATCH – Modify the parameters of a particular server.

How do I enable https on nginx?

To set up an HTTPS server, in your nginx. conf file include the ssl parameter to the listen directive in the server block, then specify the locations of the server certificate and private key files: server { listen 443 ssl; server_name www.example.com; ssl_certificate www. example.com.


3 Answers

Unfortunately, it's not possible because nginx needs to load the whole SSL server configuration at start time.

Source: https://t37.net/the-good-the-bad-and-the-ugly-of-virtual-hosting-with-nginx.html

like image 71
voondo Avatar answered Oct 21 '22 03:10

voondo


Since Nginx version 1.15.9 variables are supported in "ssl_certificate" and "ssl_certificate_key" directives.

like image 35
Oleg Neumyvakin Avatar answered Oct 21 '22 03:10

Oleg Neumyvakin


You can load them dynamically by using lua. You need to figure out how you want to map and fetch them though.

Here is an example of loading them from a database: https://github.com/Vestorly/nginx-dynamic-ssl/blob/master/conf/nginx.conf

like image 41
Laus Brandt Avatar answered Oct 21 '22 04:10

Laus Brandt