Difficulty configuring virtual host

good day all I want to configure my virtual hosts based on the srcip of
the client, so basically the ip of the connecting client determines what
document root to set.

Any ideas how this can be accomplished?

– Thank you for your time
– Paul G Webster
– Checkout Opera M2 @ Opera Web Browser | Faster, Safer, Smarter | Opera

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;
}

On Sun, 11 Mar 2012 00:47:54 -0000, Paul G Webster
[email protected] wrote:


nginx mailing list
[email protected]
mailman.nginx.org archive

–

– Thank you for your time
– Paul G Webster
– Checkout Opera M2 @ Opera Web Browser | Faster, Safer, Smarter | Opera

I should probably add as someone just pointed out to me on IRC .. if
there
is a way of doing this without ifs I would be more than happy to use it,
it was an example only 8)

On Sun, 11 Mar 2012 00:57:27 -0000, Paul G Webster
[email protected] wrote:

On Sun, 11 Mar 2012 00:47:54 -0000, Paul G Webster

– Paul G Webster
– Checkout Opera M2 @ Opera Web Browser | Faster, Safer, Smarter | Opera


nginx mailing list
[email protected]
mailman.nginx.org archive

–

– Thank you for your time
– Paul G Webster
– Checkout Opera M2 @ Opera Web Browser | Faster, Safer, Smarter | Opera

On 11 Mar 2012 01h57 CET, [email protected] 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] Module ngx_http_geo_module

Ahh smart it should work perfectly any way to set the server_name
dynamically

On Sun, 11 Mar 2012 01:13:38 -0000, Antnio P. P. Almeida
[email protected] wrote:

}
server {
nginx mailing list
[email protected]
mailman.nginx.org archive

–

– Thank you for your time
– Paul G Webster
– Checkout Opera M2 @ Opera Web Browser | Faster, Safer, Smarter | Opera

Works perfectly thank you :slight_smile:

On Sun, 11 Mar 2012 01:13:49 -0000, Paul G Webster
[email protected] wrote:

if (srcip == 4.4.4.5) {
4.4.4.5 /usr/local/www/4.4.4.5;

— appa

[1] Module ngx_http_geo_module


nginx mailing list
[email protected]
mailman.nginx.org archive

–

– Thank you for your time
– Paul G Webster
– Checkout Opera M2 @ Opera Web Browser | Faster, Safer, Smarter | Opera