Welcome! Log In Create A New Profile

Advanced

Blocking by user agent if ip doesn't match

May 31, 2011 02:49PM
Hello everyone. Sorry for double posting this question in How to section of the forum but I've noticed later there is a lot of un-replied threads there and that mailing list is more active so I am assuming I have more chance of getting some help here.

I am hoping this is possible and I'd really appreciate some help on configuring it.
We are having some bots on our site that are using google spider user agent but they are fake and their ip range has nothing to do with Google.
So I am looking for some solution that would match visitors with user agent is Google who's ip doesn't start with for example 66.x or 70.x and block them from accessing.

I've found this example on one site
if ($http_user_agent ~ (Purebot|Lipperhey|MaMa CaSpEr|libwww-perl|Mail.Ru|gold crawler) ) {
return 403;
}

But I don't know how to add ip regex match to that and what end result would be. Or negative match in this case I guess.
It is something like this for htaccess !^66.*$ to match those ips that don't start with 66. for example. But again I am not sure what the right syntax would be in nginx config or if it is even possible to match both statements.
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: 123
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready