Welcome! Log In Create A New Profile

Advanced

Re: How can I redirect some IP addresses?

Ruslan Ermilov
July 02, 2012 06:18AM
On Sun, Jul 01, 2012 at 12:16:31AM -0400, Jiff wrote:
> Hi forulisters,
>
> I've got a bunch of IP addresses and IP ranges I'd like
> to redirect to, let's say the amnesty international site
> (they're mainly from gov).
>
> I read http://wiki.nginx.org/HttpAccessModule but as I've
> got many of them I'm wondering if nginx can read a text
> file (or something else) instead of put all these addresses
> in a block?

I think you want the geo module instead:

http://nginx.org/en/docs/http/ngx_http_geo_module.html

It supports the "include" directive inside the "geo" block.
(Currently it lacks the IPv6 support though.)

> I'd also like if I can have a round-robin of redirections
> (once for amnesty, next to copwatch, etc)?

While not exactly what you want, but you can use the "split
clients" module to match $remote_port to a particular URL:

http://nginx.org/en/docs/http/ngx_http_split_clients_module.html

(This has a limitation: it will always give you the same
redirection URL over one persistent connection.)

http {
geo $wrapped {
127.0.0.1 1;
# include conf/wrapped.conf;
}

split_clients "${remote_port}AAA" $redirect {
33% http://url1;
33% http://url2;
* http://url3;
}

server {
if ($wrapped) {
return 301 $redirect;
}

location / {
return 200 "normal content";
}
}
}

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

How can I redirect some IP addresses?

Jiff July 01, 2012 12:16AM

Re: How can I redirect some IP addresses?

Francis Daly July 01, 2012 05:56AM

Re: How can I redirect some IP addresses?

Ruslan Ermilov July 02, 2012 06:18AM

Re: How can I redirect some IP addresses?

Jiff July 03, 2012 03:13PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 310
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready