Nginx 禁止部分 User-Agrent 访问
生活随笔
收集整理的這篇文章主要介紹了
Nginx 禁止部分 User-Agrent 访问
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
經常有一些垃圾爬蟲,完全不管你受得了受不了,完全不管你的 robots.txt ,拼命的爬你的網站,用下面方面可以幫這幫垃圾干掉。
location / {
??? root?? /home/www/;
??? if ($http_user_agent ~* "qihoobot") {
??? ??? return 403;
??? }
??? #...
}
然后重啟 nginx
kill -HUP `cat logs/nginx.pid` 或者 killall -s HUP nginx
可以用 curl 測試一下
curl -I -A "qihoobot" localhost
如果返回 403 就正常了。
向一切垃圾爬蟲宣戰!!!
?轉載于:https://www.cnblogs.com/lost-1987/articles/3328354.html
總結
以上是生活随笔為你收集整理的Nginx 禁止部分 User-Agrent 访问的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MySQL : 报错:1130-host
- 下一篇: CentOS 6.3 下编译Nginx(