六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 723|回复: 0

Nginx屏蔽百度爬虫

[复制链接]
 楼主| 发表于 2015-2-6 11:18:55 | 显示全部楼层 |阅读模式
Nginx屏蔽百度爬虫
公司的灰度测试环境使用的是Nginx,可以通过公网访问,但是为了避免测试环境的数据被搜索引擎的爬虫收录,所以需要在Nginx上做限制,拒绝这些可恶的爬虫访问.
修改Nginx.conf文件,具体的配置信息如下:
server {
listen 80;
server_name it.agoit.com;
if ($http_user_agent ~* "qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot")
{
return 403;
}
添加完,重启Nginx
不可能在这里等百度爬虫访问,自己用Charles修改http头,(compatible;+Baiduspider/2.0;,然后再请求,服务器返回403,证明这个配置有效,呵呵。

Nginx屏蔽百度爬虫
摘自:http://www.51testing.com/html/66/146566-813881.html
该会员没有填写今日想说内容.
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表