This is actually fairly easy as soon as you learn of [i]Embeddable Perl[/i]. Your nginx binary has to be configured with --with-http_perl_module to support Perl this way.
Once that is done you can do something like that:
[code]
http {
perl_set $storage_path '
sub {
my $r = shift;
my $host = $r->header_in("Host");
return join "/", split(//, substr($host,0,3));
}
';
}
[/code]
In the server directive you can access the previously set $storage_path, e.g.
[code]
server {
location ~ /matchsomething$ {
root /srv/www/htdocs/$storage_path;
}
}
[/code]
HTH someone else,
Fabio.
http://www.linux-showroom.com
Edited 1 time(s). Last edit at 04/09/2010 12:24PM by OpenHaus.