我知道这些IP是假的谷歌机器人,我想阻止它们。IP不是静态的,所以我想在CloudFlare中阻止范围。
但是它不起作用。
以下是google fake bot的示例日志:
https://gyazo.com/f4bd7182923c6caa92cf95a7f84116cd
以下是假的机器人IP:
162.158.74.61
162.158.74.175
162.158.75.188
162.158.75.68
162.158.75.230
162.158.75.242
162.158.75.26
162.158.74.205
172.68.58.213
172.68.58.141
172.68.58.21
172.68.59.40
172.68.59.184
108.162.216.176
108.162.216.248
108.162.216.92
这是我当前的cloudflare配置:https://gyazo.com/91af7d0964621c95d5cc5a462724cb9a
有什么办法吗?
最佳答案
添加到http块中的/etc/nginx/nginx.conf
:
geo $fakebotip {
default 0;
108.162.0.0/16 1;
141.101.0.0/16 1;
162.158.0.0/16 1;
172.68.0.0/16 1;
172.69.0.0/16 1;
}
然后转到
/etc/nginx/sites-available/your-site.pl
:if ($fakebotip = 1) {
set $naughtyBot A;
}
if ($http_user_agent ~ (Googlebot|SemrushBot|AhrefsBot|bingbot|Qwantify|YandexBot|YandexImages|DotBot|linkfluence|Mediatoolkitbot|BoardReader) ) {
set $naughtyBot "${naughtyBot}B";
}
if ($naughtyBot = AB) {
return 404;
}
检查nginx配置:
sudo nginx -t
如果一切顺利,重新加载nginx:
sudo systemctl reload nginx