Map FastCGI Ports Dynamically

justin nginx-forum at
Wed Feb 22 02:58:09 UTC 2012

I have a config file that handles wildcard subdomains like:

server_name ~^(?<user>.+)\.mydomain\.com$;

Then the variable $user contains the subdomain. The problem, is that I
also need to dynamically set the port that fastcgi passes PHP work too
since each user has their own PHP-FPM pool.


Is there a way to setup a hashmap of something like:

user          fastcgi-port
--------       ---------------
bob            9001
john           9002
kelly           9003

So that nginx can do some magic like:

set $user_port = map($user);


Posted at Nginx Forum:,222820,222820#msg-222820

More information about the nginx mailing list