# Variable substition inconsistency

**URL:** <https://www.ruby-forum.com/t/variable-substition-inconsistency/221407>\
**Category:** NGINX\
**Created:** [July 12, 2012, 11:05pm UTC](https://www.ruby-forum.com/t/variable-substition-inconsistency/221407 "2012-07-12T23:05:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [July 12, 2012, 11:05pm UTC](https://www.ruby-forum.com/t/variable-substition-inconsistency/221407/1 "2012-07-12T23:05:45Z")

</div>

Hi List,

Here’s a section of my configuration:

set $site [mysite.com](http://mysite.com);  
root /var/www/$site;  
server\_name $site;  
access\_log /var/log/nginx/${site}\_access.log;  
error\_log /var/log/nginx/${site}\_error.log;

In this example root and access\_log gets substituted, server\_name and  
error\_log doesn’t. Where can I look up that in which contexts  
substitution works?

Laci

Posted at Nginx Forum:

> **[Variable substition inconsistency](https://forum.nginx.org/read.php?2,228546,228546#msg-228546)**
>
> Hi List, Here's a section of my configuration: set $site mysite.com; root /var/www/$site; server\_name $site; access\_log /var/log/nginx/${site}\_access.log; error\_log /var/log/nginx/${site}\_error.log; In this example root and acc

---

<div class="post-metadata">

**Author:** ![mondalaci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/77aa72/32.png) [@mondalaci](https://www.ruby-forum.com/u/mondalaci)\
**Post date:** [July 12, 2012, 11:16pm UTC](https://www.ruby-forum.com/t/variable-substition-inconsistency/221407/2 "2012-07-12T23:16:51Z")

</div>

Hello!

On Thu, Jul 12, 2012 at 05:05:24PM -0400, mondalaci wrote:

> In this example root and access\_log gets substituted, server\_name and  
> error\_log doesn’t. Where can I look up that in which contexts  
> substitution works?

If variables are supported, it’s explicitly documented:

> **[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#root)**
>
> This directive appeared in version 1.11.8.

> **[Module ngx\_http\_log\_module](http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log)**
>
> The ngx\_http\_log\_module module writes request logs in the specified format.

Note well: the above config snippet suggests you don’t need  
variables, but need some configuration macros instead. Variables  
are evaluated at run time for each request and it’s bad idea to  
use them just to replace several static strings. Use your  
favorite macro processor instead if you need to.

Maxim D.

---

<div class="post-metadata">

**Author:** ![mondalaci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/77aa72/32.png) [@mondalaci](https://www.ruby-forum.com/u/mondalaci)\
**Post date:** [July 13, 2012, 2:10am UTC](https://www.ruby-forum.com/t/variable-substition-inconsistency/221407/3 "2012-07-13T02:10:57Z")

</div>

Thanks a lot for explaining, Maxim!

I didn’t know that variables are evaluated at run time. I won’t use  
them for sure then. Having only a couple of server blocks I don’t need  
to use macro processors yet.

Cheers,  
Laci

Posted at Nginx Forum:

> **[Re: Variable substition inconsistency](https://forum.nginx.org/read.php?2,228546,228554#msg-228554)**
>
> Hi List, Here's a section of my configuration: set $site mysite.com; root /var/www/$site; server\_name $site; access\_log /var/log/nginx/${site}\_access.log; error\_log /var/log/nginx/${site}\_error.log; In this example root and acc
