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.