variables in "include"

Kaspars Dambis kaspars at
Mon Jul 20 14:40:49 MSD 2009

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