Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is it possible to configure nginx so that domain/~user is proxied to a port set aside for that user.

Then the user can run another instance of nginx or unicorn on that port.

Is that possible? I would like a database which controls the user to port number relationship though.

share|improve this question

migrated from Mar 21 '11 at 13:52

This question came from our site for computer enthusiasts and power users.

1 Answer 1

up vote 1 down vote accepted

You could use a combination of nginx map and rewrite modules. You would need a script to generate the map configuration out of the database, though.

The target configuration would look like this:

map $uri $new {
  include        /path/to/usermap.txt; 

server {
  rewrite  ^    $new   redirect;

With /path/to/usermap.txt being generated by a script with an output similar to this:

# automatically generated by a script
/~bob  ;
share|improve this answer
is that like a c switch statement? – Joseph Le Brech Mar 21 '11 at 14:27
Not sure what you mean, are you referring to the example provided in the link to map documentation? – zarkdav Mar 21 '11 at 14:29
yes i meant the example in the document is mapping urls to folders? am i right? i could map ~users to sockets in the users home directory? – Joseph Le Brech Mar 21 '11 at 14:31
No, the example in the documentation is showing how to redirect different paths to different hosts. – zarkdav Mar 21 '11 at 14:47
i understand this now, thanks :) – Joseph Le Brech Mar 21 '11 at 15:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.