|
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
|
|