map module - mass hosting

beatnut nginx-forum at nginx.us
Wed Apr 23 12:07:42 UTC 2014


Hello all,

I'd like to use map module for my vhost configuration to setup user name in
root or fastcgi_pass parameter.

At this point i've 300 domains configured and my config look like this:

http
{
       server {
       ..........
    root /home/someuser;

    	location ~ \.php$ {
		try_files $uri =404;
		fastcgi_pass unix:/var/www/someuser/fpm.socket;
		
		include fastcgi_params.conf;
	}

     ............
      }

}


I'd like to replace this model by using map module like this


http
{

#map with about 300 domains

map $http_host $username {
example.com someuser;
escample2.com someuser2;
.......

}

       server {
       ..........
        root /home/$username;

      include fastcgi.conf;	

     ............
      }

}


fastcgi.conf:

location ~ \.php$ {
		try_files $uri =404;
		fastcgi_pass unix:/var/www/$username/fpm.socket;
		
		include fastcgi.conf;
	}


My question is -  Is this a good idea to use map like this ? Every request
needs to find out username by $http_host searching through few hundreds of
domains.  Maybe i'm wrong   but it can slow down request processing
significantly.
Any suggestions ?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,249475,249475#msg-249475



More information about the nginx mailing list