Nginx – How to add a Map Variable to a String

user1179459 asked:

I have below configuration in my nginx.conf, however, for some reason, it doesn’t recognise the $site_name as a variable

map $host $site_name {
error_log  /var/www/vhosts/{$site_name}/httpdocs/var/logs/nginx/error.log error;

The error I get is

nginx: [emerg] open() "/var/www/"$site_name"/httpdocs/var/logs/nginx/error.log" failed (2: No such...irectory)

My answer:

The error_log directive does not support the use of variables. So you don’t.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.