Answer the question
In order to leave comments, you need to log in
How to block bots on nginx less resourcefully - by IP or user-agent?
There is a VPS with ISPmanager panel and nginx+php-fpm. Bot PetalBot storms one of the sites (but I would even block it for everyone just in case). It is better to prescribe access prohibition by user-agent in the nginx config for the site
if ($http_user_agent ~* PetalBot) {
return 403;
}
location / {
deny 114.119.160.0/16;
deny 114.119.161.0/16;
deny 114.119.162.0/16;
deny 114.119.163.0/16;
deny 114.119.164.0/16;
deny 114.119.165.0/16;
deny 114.119.166.0/16;
deny 114.119.167.0/16;
}
Answer the question
In order to leave comments, you need to log in
Kill on the firewall by address ranges - then nothing will appear in the logs.
If the attacks are targeted, then a hacker can change the user_agent without any problems. I advise you to ban both by IP address and by user_agent.
That's only if you are blocking exactly unwanted bots, it's better to `return 444;`
Yes, I also created an overload. This is a huawei search engine robot - https://vk.com/@news_newusman-rss-722804822-1394310157 - just block it in robots. You can still end up in htaccess or nginx, to be sure.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question