Welcome! Log In Create A New Profile

Advanced

Re: Nginx mass dynamic virtual hosts like apache?

Alexandr Gomoliako
November 19, 2011 05:56PM
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
Subject Author Posted

Nginx mass dynamic virtual hosts like apache?

anagio November 19, 2011 05:25PM

Re: Nginx mass dynamic virtual hosts like apache?

Alexandr Gomoliako November 19, 2011 05:56PM

Re: Nginx mass dynamic virtual hosts like apache?

anagio November 19, 2011 07:17PM

Re: Nginx mass dynamic virtual hosts like apache?

anagio November 19, 2011 07:41PM

Re: Nginx mass dynamic virtual hosts like apache?

Alexandr Gomoliako November 19, 2011 07:34PM

Re: Nginx mass dynamic virtual hosts like apache?

Alexandr Gomoliako November 19, 2011 07:58PM

Re: Nginx mass dynamic virtual hosts like apache?

anagio November 20, 2011 04:42AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 109
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready