Nginx屏蔽百度爬虫

上一篇 / 下一篇  2012-05-17 14:34:42 / 个人分类:服务器日常维护

G*~s/T w6D H6z4M4?$s0公司的灰度测试环境使用的是Nginx,可以通过公网访问,但是为了避免测试环境的数据被搜索引擎的爬虫收录,所以需要在Nginx上做限制,拒绝这些可恶的爬虫访问.51Testing软件测试网f8B9xq M'f)g

\u5k4t~/j)N6V0修改Nginx.conf文件,具体的配置信息如下:
7pp&s']_0server {51Testing软件测试网MZ:i&kfsZjI d
listen 80;51Testing软件测试网6mE6q \4[I5OzN%e
server_namewww.ready.com;51Testing软件测试网IZ Q$^%bci
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")
{^){U5Ad"e(so0{51Testing软件测试网4R{#Mz$@4E
return 403;51Testing软件测试网/a;T%I4Q\Wk0bsS
}51Testing软件测试网^r~/`3R&[Q6U9zZ{

'b9Y7K"Q1}+q%z0添加完,重启Nginx

;?-Ux R0Wr"{7[5`Q.L0B0

rE,H5ia{,\+v0不可能在这里等百度爬虫访问,自己用Charles修改http头,(compatible;+Baiduspider/2.0;,然后再请求,服务器返回403,证明这个配置有效,呵呵。51Testing软件测试网 |b-bH5H u!C E;~


TAG: nginx Nginx NGINX 拒绝爬虫

引用 删除 namixu   /   2012-05-17 14:52:56
 

评分:0

我来说两句

日历

« 2024-03-28  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 32881
  • 日志数: 8
  • 建立时间: 2011-11-23
  • 更新时间: 2013-11-01

RSS订阅

Open Toolbar