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 @ http://www.opera.com/mail/

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]
http://mailman.nginx.org/mailman/listinfo/nginx

– Thank you for your time
– Paul G Webster
– Checkout Opera M2 @ http://www.opera.com/mail/

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 @ http://www.opera.com/mail/


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

– Thank you for your time
– Paul G Webster
– Checkout Opera M2 @ http://www.opera.com/mail/

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] http://nginx.org/en/docs/http/ngx_http_geo_module.html

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]
http://mailman.nginx.org/mailman/listinfo/nginx

– Thank you for your time
– Paul G Webster
– Checkout Opera M2 @ http://www.opera.com/mail/

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] http://nginx.org/en/docs/http/ngx_http_geo_module.html


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

– Thank you for your time
– Paul G Webster
– Checkout Opera M2 @ http://www.opera.com/mail/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs