nginx dynamic virtual hosts

Posted by Anagio on Server Fault See other posts from Server Fault or by Anagio
Published on 2011-11-19T23:01:21Z Indexed on 2011/11/20 9:58 UTC
Read the original article Hit count: 204

Filed under:
|

With nginx is there a method to setup mass dynamic virtual hosts similar to the way apache2 can be configured? I'm setting up an saas application each user will have their own subdomain and i'd like to use nginx over apache2.

Thanks

Code below should be how to configure

map $http_host $subdir {
hostnames;
default "default";
.foo.bar.com "foo";
.baz.bar.com "baz";
}

server {
root /path/to/$subdir;

}

© Server Fault or respective owner

Related posts about nginx

Related posts about virtualhost