admin管理员组文章数量:1384114
I have some code I use for my apache driven websites, but recently have inherited a site that is using Nginx, so I can't use an htaccess directive there. Can anyone point me in the proper direction to put this in Nginx speak:
SetEnvIfNoCase User-agent (yandex|baidu|spider|mj12|blex|webmeup
|ichiro|moget|naverbot|sogou|youdao|majestic|copyscape|sitesnagger
|teleportpro|copier|reaper|stripper|webzip|peek|scrape
|grub|linkdex|zyb|zibber|bullseye|blowfish|backdoor|spyder
|download|demon|linklooker|emailcollector|emailsiphon|emailwolf
|creep|getright|suck|ninja|ahrefsBot|semrush|petalbot
|dataforseobot|semrush|dotbot|meta) badbot=1
Order Allow,Deny
Allow from ALL
Deny from env=badbot
I have some code I use for my apache driven websites, but recently have inherited a site that is using Nginx, so I can't use an htaccess directive there. Can anyone point me in the proper direction to put this in Nginx speak:
SetEnvIfNoCase User-agent (yandex|baidu|spider|mj12|blex|webmeup
|ichiro|moget|naverbot|sogou|youdao|majestic|copyscape|sitesnagger
|teleportpro|copier|reaper|stripper|webzip|peek|scrape
|grub|linkdex|zyb|zibber|bullseye|blowfish|backdoor|spyder
|download|demon|linklooker|emailcollector|emailsiphon|emailwolf
|creep|getright|suck|ninja|ahrefsBot|semrush|petalbot
|dataforseobot|semrush|dotbot|meta) badbot=1
Order Allow,Deny
Allow from ALL
Deny from env=badbot
Share
Improve this question
asked Mar 17 at 20:52
pathfinderpathfinder
1,7961 gold badge19 silver badges22 bronze badges
1 Answer
Reset to default 0if ($http_user_agent ~ "yandex|baidu|spider|mj12|blex|webmeup|ichiro|moget|
naverbot|sogou|youdao|majestic|copyscape|sitesnagger|teleportpro|copier|
reaper|stripper|webzip|peek|scrape|grub|linkdex|zyb|zibber|bullseye|
blowfish|backdoor|spyder|download|demon|linklooker|emailcollector|emailsiphon|
emailwolf|creep|getright|suck|ninja|ahrefsBot|semrush|petalbot|dataforseobot|
semrush|dotbot|meta|OAI-SearchBot|ChatGPT|GPTBot|Claude|anthropic|CCBot|
cohere-ai|ImagesiftBot|Perplexity|Omigili|CrowdTanglebot|LinkisBot|
TweetmemeBot|LivelapBot|Openbot|Snooper|aiHitBot|Huaweisymantecspider")
{ return 444; }
This works great for me, and additionally if you return 444 it only closes connection on your end without returning anything and hopefully leave the bot at the other end eating it's own resources for a while.
If you want to be proper you should probably send back a 403.
本文标签: setenvHow to write a SetEnvIf directive for Nginx to block bad bots and spidersStack Overflow
版权声明:本文标题:setenv - How to write a SetEnvIf directive for Nginx to block bad bots and spiders - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744535549a2611292.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论