variables in "include" for vhost specific config files

Kaspars kaspars at
Sun Jul 19 21:45:07 MSD 2009

Privet Igor and dear list members,

I am trying to create a flexible virtual host environment, where each 
host could have their own config.nginx file.

In sites-available/default I have:

server {
         listen   80 default;
         server_name _;
         server_name_in_redirect off;

         set $vhost_path /var/www/vhosts;

         root    $vhost_path/$host;
         index   index.php index.html index.htm;

         # THE IMPORTANT BIT: vhost specific config files, for rewrites, 
         include /var/www/vhosts/$host/config.nginx;


'root' directive works fine, but the 'include' doesn't like the $host 
variable in it.

I would like to avoid using server { ... } for each of the individual 
hosts, in order to have global php settings.

What would be the best way to approach this?

Any pointers and suggestions are very welcome.


p.s. using nginx 0.6.32-3 on debian lenny.

More information about the nginx mailing list