deny by ip and redirect

helen nginx-forum at nginx.us
Sun Oct 17 19:28:23 MSD 2010


On Sun, 17 Oct 2010 10:36:42 -0400, Ilan Berkner  wrote:

[...]
> The above code works as expected, but I would like to do something
like
> this:
>
> location / {
>   if not 1.1.1.1 or 1.1.1.2 or 1.1.1.3 do a 301 redirect to
> www.domain.com(with request uri)
> }
>
> is this possible?

Use the nginx geo module  to set up a boolean-style variable - say,
$internal_ip.  Then put something like this in the server block for your
test site:
	
if ($internal_ip != 1) {
	rewrite ^ http://your.public.site/ permanent;
}

helen

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,141550,141558#msg-141558




More information about the nginx mailing list