发布于 4年前

nginx 判断是否是爬虫

set $spider '0';
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") {
    set $spider '1';
}

if ($spider = '1') {
    return 200 "给爬虫倒一杯卡布奇诺";
}

if ($spider = '0') {
    proxy_pass http://127.0.0.1:3000;
}
©2020 edoou.com   京ICP备16001874号-3