How to setup mass dynamic virtual hosts in nginx?

jM2.me picture jM2.me · Nov 20, 2011 · Viewed 26.4k times · Source

Been playing with nginx for about an hour trying to setup mass dynamic virtual hosts. If you ever done it in apache you know what I mean.

Goal is to have dynamic subdomains for few people in the office (more than 50)

Answer

Hangster picture Hangster · Jan 22, 2013

Perhaps doing this will get you where you want to be:

server {

    root /sites/$http_host;

    server_name $http_host;

    ...

}

I like this as I can literally create sites on the fly, just create new directory named after the domain and point the DNS to the server ip.