deny by ip and redirect

Ilan Berkner iberkner at gmail.com
Sun Oct 17 20:29:14 MSD 2010


Thanks Igor, appreciate the information, is this something you expect to be
done in coming versions?

For my purposes for now, this is acceptable.

Thanks

On Sun, Oct 17, 2010 at 12:25 PM, Igor Sysoev <igor at sysoev.ru> wrote:

> On Sun, Oct 17, 2010 at 12:17:55PM -0400, Ilan Berkner wrote:
>
> > Is there a way to do it with a 301?
>
> It should be implemented as
> error_page 403 =301 http://www.primarydomain.com$request_uri;
> but currently this is not implemented.
>
> > On Sun, Oct 17, 2010 at 12:11 PM, Igor Sysoev <igor at sysoev.ru> wrote:
> >
> > > On Sun, Oct 17, 2010 at 12:00:09PM -0400, Ilan Berkner wrote:
> > >
> > > > Thank you, I actually resolved it by:
> > > >
> > > > location / {
> > > >   allow 1.1.1.1;
> > > >   deny all;
> > > >   error_page 403 = @redirect_towww;
> > > > }
> > > >
> > > > location @redirect_towww
> > > > {
> > > >   rewrite ^(.*) http://www.primarydomain.com$1 permanent;
> > > > }
> > >
> > > error_page 403  http://www.primarydomain.com$request_uri;
> > >
> > > However, you can not set 301 code.
> > >
> > > > On Sun, Oct 17, 2010 at 11:28 AM, helen <nginx-forum at nginx.us>
> wrote:
> > > >
> > > > > 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
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > nginx mailing list
> > > > > nginx at nginx.org
> > > > > http://nginx.org/mailman/listinfo/nginx
> > > > >
> > >
> > > > _______________________________________________
> > > > nginx mailing list
> > > > nginx at nginx.org
> > > > http://nginx.org/mailman/listinfo/nginx
> > >
> > >
> > > --
> > > Igor Sysoev
> > > http://sysoev.ru/en/
> > >
> > > _______________________________________________
> > > nginx mailing list
> > > nginx at nginx.org
> > > http://nginx.org/mailman/listinfo/nginx
> > >
>
> > _______________________________________________
> > nginx mailing list
> > nginx at nginx.org
> > http://nginx.org/mailman/listinfo/nginx
>
>
> --
> Igor Sysoev
> http://sysoev.ru/en/
>
> _______________________________________________
> 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/2abf1267/attachment.html>


More information about the nginx mailing list