Vhost support

Igor Sysoev igor at sysoev.ru
Sat Jan 29 10:06:57 MSK 2011


On Sat, Jan 29, 2011 at 05:04:23PM +1000, Mark Constable wrote:

> 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?

http://nginx.org/en/docs/http/server_names.html#regex_names


-- 
Igor Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list