More subdomain mapping (dynamic 'root'?)

Frank Louwers frank at
Fri Jul 3 13:36:24 MSD 2009

On 01 Jul 2009, at 12:23, miradev wrote:

> I want to be able to map submains and urls to determined locations  
> on disk, if they exist.
> The URL structure is something like:
> Where  would letters, numbers and underscores , and  is a domain  
> name (e.g.

This is what we do for a customer: this allows them to create new  
domains/projects just by making a new directory. With passenger and  
php-fpm and this setup, he doesn't need to restart/reload *anything*  
to start a new website.

server {
         listen       80;
         server_name  _;
         server_name_in_redirect off;
         passenger_enabled on;
         passenger_use_global_queue on;
         root   /home/customer/sites/$host/public;

         if (!-d $document_root) {
                 #site not (yet) configureerd. Serve default
                 rewrite (.*) http://default.customer.tld/;

         location / {
           passenger_enabled on;
                 index index.html index.htm index.php;
         location ~ .php$ {
                 fastcgi_index index.php;
                 include fastcgi_params;


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list