toxic

备忘录

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

经常有一些垃圾爬虫,完全不管你受得了受不了,完全不管你的 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 就正常了。

向一切垃圾爬虫宣战!!!

 
 

posted on 2013-09-18 14:22  toxic  阅读(306)  评论(0编辑  收藏  举报