Blocking by user agent if ip doesn't match

Alexandr Gomoliako zzz at zzz.org.ua
Tue May 31 23:19:13 MSD 2011


On 5/31/11, karabaja <nginx-forum at nginx.us> wrote:
> syntax would be in nginx config or if it is even possible to match both
> statements.

It is possible and there are different ways to match two conditions. I
like this one:

geo $google {
    default 0;
    66.0.0.0/8 1;
}
map $http_user_agent $googlebot {
    default 0;
    ~google  $google;
}

server {
    location / {
        if ($googlebot) {
            ...
        }
    }
}



More information about the nginx mailing list