On Sun, Nov 20, 2011 at 12:25 AM, anagio <nginx-forum@nginx.us> wrote:
> Hello
>
> I'm new to nginx and was wondering if there is a configuration that is
> similar to apaches mass dynamic virtual hosts
> http://httpd.apache.org/docs/2.0/vhosts/mass.html
>
> I'm having an SaaS developed where users will get a subdomain and would
> like to set this up as efficiently as possible. As of now i'm using
> apache but would like to move to nginx and get this setup
Well, the idea is to set your root dynamically from the default
server block depending on the 'host' header.
You can either use $http_host as a part of your root, which
is probably not a good thing, or map it to some subdir, and
use its value instead:
map $http_host $subdir {
hostnames;
default "default";
.foo.bar.com "foo";
.baz.bar.com "baz";
}
server {
root /path/to/$subdir;
}
Hope this helps.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx