Difficulty configuring virtual host

António P. P. Almeida appa at perusio.net
Sun Mar 11 01:13:38 UTC 2012


On 11 Mar 2012 01h57 CET, opensource at interflective.com wrote:

> Ideally doing this:
>
> if (srcip == 4.4.4.5) {
> server_name test1;
> root /usr/local/www/4.4.4.5;
> } elsif (srcip == 2.2.2.2) {
> server_name test2;
> root /usr/local/www/2.2.2.2;
> }

Untested. Using the geo module [1]. At the http level.

geo $root_dir {
    4.4.4.5 /usr/local/www/4.4.4.5;
    2.2.2.2 /usr/local/www/2.2.2.2;
}

At the server level (vhost).

server {
    server_name test1 test2;
    root $root_dir; 
    #...  
}

--- appa

[1]  http://nginx.org/en/docs/http/ngx_http_geo_module.html



More information about the nginx mailing list