1. [代码]定义 Map 跳至 [1] [2] [3] [全屏预览] view source print ? 1map $http_user_agent $is_bot { 2 default 0; 3 ~[a-z]bot[^a-z] 1; 4 ~[sS]pider[^a-z] 1; 5 'Yahoo! Slurp China' 1; 6 'Mediapartners-Google' 1; 7} 2. [代码]定义 Location 1location @bots { 2 proxy_pass http://osc_bot; 3} 3. [代码]处理爬虫请求 1location / { 2 error_page 418 =200 @bots; 3 if ($is_bot) { 4 return 418; 5 } 6 proxy_pass http://osc_tomcats; 7}