Welcome! Log In Create A New Profile

Advanced

Re: Blocking by user agent if ip doesn't match

António P. P. Almeida
May 31, 2011 06:28PM
On 31 Mai 2011 23h01 WEST, nginx-forum@nginx.us wrote:

> Thanks everyone for being so helpful. I've ended up applying Igor's
> suggestion. But I've dropped this line as I wasn't sure what to do
> with it:
> "~(?i)(Purebot|Lipperhey|MaMaCaSpEr|libwww-perl|Mail.Ru|gold
> crawler)" 1;
>
> I am guessing it can be used if I want to match more then just
> google's user agent. But in any case what I did worked very nice. I
> tested it using Firefox user agent and I got forbidden page, then
> tried adding my ip to geo bit and I was allowed.

Yes following Alexandr and Igor's advice you can create similar
variables using more IP blocks inside the geo directive. E.g.:

geo $bad_bot {
default 1;
66.0.0.0/8 0;
xx.yy.zz.ww/16 1; # for Yahoo!
(...)
}

You'll need also to add the regexes for User Agent string of the
remaining bots that you want to whitelist in the map directive.

map $http_user_agent $bots {
default 0;
~(?i)(google|yahoo) $bad_bot;
}

--- appa

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

Blocking by user agent if ip doesn't match

karabaja May 31, 2011 02:49PM

Re: Blocking by user agent if ip doesn't match

António P. P. Almeida May 31, 2011 03:06PM

Re: Blocking by user agent if ip doesn't match

Alexandr Gomoliako May 31, 2011 03:20PM

Re: Blocking by user agent if ip doesn't match

Igor Sysoev May 31, 2011 03:36PM

Re: Blocking by user agent if ip doesn't match

Alexandr Gomoliako May 31, 2011 04:36PM

Re: Blocking by user agent if ip doesn't match

António P. P. Almeida May 31, 2011 05:06PM

Re: Blocking by user agent if ip doesn't match

Alexandr Gomoliako May 31, 2011 05:30PM

Re: Blocking by user agent if ip doesn't match

Igor Sysoev June 01, 2011 03:26AM

Re: Blocking by user agent if ip doesn't match

Hari Hendaryanto June 01, 2011 04:48AM

Re: Blocking by user agent if ip doesn't match

Igor Sysoev June 01, 2011 04:50AM

Re: Blocking by user agent if ip doesn't match

karabaja May 31, 2011 06:01PM

Re: Blocking by user agent if ip doesn't match

António P. P. Almeida May 31, 2011 06:28PM

Re: Blocking by user agent if ip doesn't match

António P. P. Almeida May 31, 2011 06:34PM

Re: Blocking by user agent if ip doesn't match

karabaja May 31, 2011 06:44PM

Re: Blocking by user agent if ip doesn't match

António P. P. Almeida May 31, 2011 07:00PM

Re: Blocking by user agent if ip doesn't match

Igor Sysoev June 01, 2011 03:30AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 73
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready