Welcome! Log In Create A New Profile

Advanced

More subdomain mapping (dynamic 'root'?)

July 01, 2009 06:23AM
I want to be able to map submains and urls to determined locations on disk, if they exist.

The URL structure is something like: [i]http://[client].admin.domain.com/[project][/i]

Where [client] would letters, numbers and underscores [a-zA-Z0-9_], and [project] is a domain name (e.g. [i]http://cnn.admin.domain.com/www.cnnminiblog.com[/i])

Nginx should check if [b]/var/www/clients/[client]/admin/[project]/html/[/b] exists and use that as root:

Some horrible pseudo code:

[code]
server {
listen localhost: 80;
server_name *.admin.domain.com;

if ($host ~ ([a-z0-9_]*).admin.domain.com) {
set $client = $1;
if ($url ~ ^([^/]*)) {
set $project = $1;
set $myroot = /var/www/clients/$client/admin/$project/html;
if ( -e $myroot ){
root $myroot;
}
}
}
...
}
[/code]

If this is not very 'nginxy', I am very open to alternate solutions.
Subject Author Posted

More subdomain mapping (dynamic 'root'?)

miradev July 01, 2009 06:23AM

Re: More subdomain mapping (dynamic 'root'?)

miradev July 02, 2009 11:29AM

Re: More subdomain mapping (dynamic 'root'?)

Frank Louwers July 03, 2009 05:36AM

Re: More subdomain mapping (dynamic 'root'?)

miradev July 03, 2009 06:42AM

Re: More subdomain mapping (dynamic 'root'?)

Frank Louwers July 03, 2009 08:56AM

Re: More subdomain mapping (dynamic 'root'?)

miradev July 03, 2009 10:19AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 85
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready