Variable substition inconsistency

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 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:

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:

http://nginx.org/r/root
http://nginx.org/r/access_log

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.

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: