deny by ip and redirect

SanCao Jie sancaojie at gmail.com
Sun Oct 17 19:24:28 MSD 2010


Hi , This is a simple setting  .Maybe it  can solve your  problem .

location / {
allow 1.1.1.1;
allow 1.1.1.2;
allow 1.1.1.3;
deny all;
}

error_page 403 /403.html;
location=/403.html{
    proxy_pass http://www.domain.com;
}





On Sun, Oct 17, 2010 at 10:36 PM, Ilan Berkner <iberkner at gmail.com> wrote:

> hi all,
>
> I'd like to only allow a certain set of ip addresses to access one of our
> test sites, and redirect anyone with a different ip address to our primary
> domain.
>
> location / {
>   allow 1.1.1.1;
>   deny all;
> }
>
> 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?
>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20101017/db55f289/attachment.html>


More information about the nginx mailing list