So there doesn’t seem to be any interest in some kind of
vhost_alias module so I’d like to try and write one but I
need a little help with the nginx codebase.
2011/01/29 16:09:13 [error] 32404#0:
*1 “/var/www/domain.org/index.html” is not found
(2: No such file or directory), client: 192.168.1.2,
server: _, request: “GET / HTTP/1.1”, host: “domain.org”
(yes, I know the /var/www/domain.org directory does not exist)
This is pretty good but I want to reverse the domain.org $host
variable and provide, say, a $rhost variable of “org/domain”.
I have an apache2 module that already does this so I just need
some orientation or assistance to find where in the nginx code
to do the same thing so any pointers would be appreciated.
On Sat, Jan 29, 2011 at 05:04:23PM +1000, Mark Constable wrote:
}
This is pretty good but I want to reverse the domain.org $host
variable and provide, say, a $rhost variable of “org/domain”.
I have an apache2 module that already does this so I just need
some orientation or assistance to find where in the nginx code
to do the same thing so any pointers would be appreciated.
Make it:
server_name
~^(?[^.])[.](?[^.])[.](?[^.])[.](?[^.]+).(?[^.]+)$;
Forgot to escape the “.” in the named capturing groups.
Thanks Antonio, this does indeed work. The only downside I can see is
that the system file path is something like /var/www////com/domain/,
when there are less than 5 parts, but it still seems to work okay.
server {
listen 80;
server_name
~^(?[^.])[.](?[^.])[.](?[^.])[.](?[^.])[.](?[^.]*)$;
I’d still be interested to do this without requiring a regex as all
it would take is something like this small amount of code in a module,
or as a patch to core…