Answer the question
In order to leave comments, you need to log in
How to correctly block NGINX bots at the server level?
In access.log, bots
crawl through SemrushBot/6~bl
bingbot/2.0
YandexBot/3.0
(compatible; SemrushBot/6~bl; +http://www.semrush.com/bot.html)
(compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)
(compatible; YandexBot/3.0; +http://yandex.com/bots)
include /etc/nginx/conf.d/*.conf;
#Список ботов
map $http_user_agent $limit_bots {
default 0;
~*(SemrushBot|SemrushBot/6~bl|YandexBot|YandexBot/3.0|bingbot|bingbot/2.0) 1;
}
location / {
if ($limit_bots = 1) { return 403;}
if (!-e $request_filename){
rewrite ^/sitemap.xml$ /sitemap.php;
rewrite ^/sitemap(\d+).xml$ /sitemap$1.php;
}
}
Answer the question
In order to leave comments, you need to log in
Thus, it is pointless to block bots. Those who honestly write about themselves in the user agent usually do not ask aggressively and, plus or minus, respect what is written in robots.txt. The vast majority of parsers who act as if they are not themselves pretend to be ordinary browsers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question