Nginx反爬虫设置
一、禁止爬虫的UA
在配置文件的server段添加如下内容
1 | 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") |
二、Robots.txt
在http://tool.chinaz.com/robots/可以针对现在的搜索引擎按照想要的规则生成robots.txt文件。