multi tenant - nginx - Subdomain as querystring parameter? -


i have simple, single-page web application accepts query string parameter, name. web application prints parameter's value; so, page @ http://example.com/app/?name=person1 displays text person1.

i use nginx internally route requests http://person1.example.com/ http://example.com/app/?name=person1 same text retrieved.

ideally, make name of subdomain available either php or node.js process in order reuse same application files across different subdomains, allowing application handle requests internally based on whichever url client accessing.

however, dynamically- without setting new virtual host every subdomain.

can done dynamic virtual hosts on nginx, , if so, how? can point me in right direction, or explain i'm struggling understand?

additionally, there better alternative attempting do?

if external redirect alright, try following:

map $host $subdomain {     ~^(?<sub>.+)\.[^\.]+\.[^\.]+$ $sub; }  server {     listen  80  default_server;     server_name _;      if ($subdomain) {         return 301 http://example.com/app/?name=$subdomain;     } } 

if internal redirect required, rewrite or proxy_pass may necessary.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -