Vhost support

Mark Constable markc at renta.net
Sat Jan 29 10:04:23 MSK 2011


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.

  server {
    listen 80;
    server_name _;
    location / {
      root /var/www/$host;
    }
  }

If I use the above then I get this in the logs...

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.

Anyone care to offers some clues?

--markc



More information about the nginx mailing list