# Using variables in certificate path names

**URL:** <https://www.ruby-forum.com/t/using-variables-in-certificate-path-names/243644>\
**Category:** NGINX\
**Created:** [December 15, 2015, 10:45am UTC](https://www.ruby-forum.com/t/using-variables-in-certificate-path-names/243644 "2015-12-15T10:45:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [December 15, 2015, 10:45am UTC](https://www.ruby-forum.com/t/using-variables-in-certificate-path-names/243644/1 "2015-12-15T10:45:26Z")

</div>

Hello!

Is it possible and correct something like:

server {  
listen 1.1.1.1:443 ssl;

```
server_name sitename.de sitename.fr sitename.nl;

```

root /var/www/vhosts/Live/public\_html;

ssl\_certificate /etc/ssl/web/$host.pem;  
ssl\_certificate\_key /etc/ssl/web/$host.key;

…  
#commont part for all sites  
…  
}

---

<div class="post-metadata">

**Author:** ![Aleksey\_Portnov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Aleksey\_Portnov](https://www.ruby-forum.com/u/Aleksey_Portnov)\
**Post date:** [December 15, 2015, 10:54am UTC](https://www.ruby-forum.com/t/using-variables-in-certificate-path-names/243644/2 "2015-12-15T10:54:12Z")

</div>

On Tuesday 15 December 2015 09:44:45 Aleksey Portnov wrote:

> ssl\_certificate /etc/ssl/web/$host.pem;  
> ssl\_certificate\_key /etc/ssl/web/$host.key;
> 
> …  
> #commont part for all sites  
> …  
> }

Currently it’s not possible. Certificates and keys  
are loaded while reading configuration.

wbr, Valentin V. Bartenev

---

<div class="post-metadata">

**Author:** ![Aleksey\_Portnov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Aleksey\_Portnov](https://www.ruby-forum.com/u/Aleksey_Portnov)\
**Post date:** [December 15, 2015, 11:01am UTC](https://www.ruby-forum.com/t/using-variables-in-certificate-path-names/243644/3 "2015-12-15T11:01:48Z")

</div>

On 12/15/15 12:53 PM, Valentin V. Bartenev wrote:

> > 
> 
> are loaded while reading configuration.

.. and we are working on a similar feature.

–  
Maxim K.

---

<div class="post-metadata">

**Author:** ![Aleksey\_Portnov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Aleksey\_Portnov](https://www.ruby-forum.com/u/Aleksey_Portnov)\
**Post date:** [December 17, 2015, 4:45pm UTC](https://www.ruby-forum.com/t/using-variables-in-certificate-path-names/243644/4 "2015-12-17T16:45:50Z")

</div>

Am 15-12-2015 11:01, schrieb Maxim K.:

> > > root /var/www/vhosts/Live/public\_html;
> > > 
> > > ssl\_certificate /etc/ssl/web/$host.pem;  
> > > ssl\_certificate\_key /etc/ssl/web/$host.key;

[snipp]

> > Currently it’s not possible. Certificates and keys  
> > are loaded while reading configuration.
> 
> .. and we are working on a similar feature.

Due to the fact that I’m not sure if it’s possible I ask 😉

Is it possible to load the certificates from $ENV{‘CERT\_PATH’}?

Sorry if I missed it in the doc.

BR aleks

---

<div class="post-metadata">

**Author:** ![Aleksey\_Portnov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Aleksey\_Portnov](https://www.ruby-forum.com/u/Aleksey_Portnov)\
**Post date:** [December 19, 2015, 10:04pm UTC](https://www.ruby-forum.com/t/using-variables-in-certificate-path-names/243644/5 "2015-12-19T22:04:06Z")

</div>

## Generating a separate server block for every certificate is the solution. Since you are probably not managing the configuration by hand at this scale, use your favourite configuration management tool with a well-cooked template to generate nginx’ configuration.

_B. R._

---

<div class="post-metadata">

**Author:** ![Aleksey\_Portnov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Aleksey\_Portnov](https://www.ruby-forum.com/u/Aleksey_Portnov)\
**Post date:** [December 19, 2015, 7:22pm UTC](https://www.ruby-forum.com/t/using-variables-in-certificate-path-names/243644/6 "2015-12-19T19:22:18Z")

</div>

On Tue, Dec 15, 2015 at 01:01:15PM +0300, Maxim K. wrote:

> > > root /var/www/vhosts/Live/public\_html;  
> > > Currently it’s not possible. Certificates and keys  
> > > are loaded while reading configuration.
> 
> .. and we are working on a similar feature.

I have similar problem.  
There is:  
server {  
listen 1.1.1.1  
listen 1.1.1.1:443  
server\_name \_ ;  
…  
}

and many locations there. Number of different hostnames might be  
thousands.  
Some of them, (hundreds) might have certificates. How to serve them with  
nginx.  
Generate separate server block {} for every certificate is not a  
solution.
