Welcome! Log In Create A New Profile

Advanced

Re: redirect some IP addresses

Maxim Dounin
June 29, 2011 01:30AM
Hello!

On Wed, Jun 29, 2011 at 01:11:38AM -0400, Jiff wrote:

> Hi forumers,
>
> As I can't test it, I'd like to know if my redirect code is correct or
> not:
>
> location / {
> if ($remote_addr ~ "^(62.160.71.0/24)"){

No, this is clearly incorrect and won't work. Use

deny 62.160.71.0/24;

instead, see http://wiki.nginx.org/HttpAccessModule for details.
Normally this will return 403 error, though this may be easily
redefined with error_page directive (see
http://wiki.nginx.org/HttpCoreModule#error_page).

If you do really need "if" testing instead of client addresses,
use geo module (http://wiki.nginx.org/HttpGeoModule) for CIDR
testing.

Maxim Dounin

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

redirect some IP addresses

Jiff June 29, 2011 01:11AM

Re: redirect some IP addresses

Maxim Dounin June 29, 2011 01:30AM

Re: redirect some IP addresses

Jiff July 07, 2011 11:53AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 114
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