set $device pc;
set $flag "";
set $spider 0;
if ($http_user_agent ~* "(iphone)|(ipod)|(android)|(mobile)|(blackberry)|(webos)|(incognito)|(webmate)|(bada)|(nokia)|(lg)|(ucweb)|(skyfire)") {
set $device mobile;
set $flag "${flag}1";
}
if ($http_user_agent ~* "(bot)|(spider)") {
set $spider 1;
}
if ($http_referer ~* "(baidu.com)|(ipod)|(android)|(mobile)|(blackberry)|(webos)|(incognito)|(webmate)|(bada)|(nokia)|(lg)|(ucweb)|(skyfire)") {
set $flag "${flag}1";
}
location / {
#default_type application/json;
#return 200 '{"status":"success","result":$flag$spider}';
if ($flag ~* "11") {
proxy_pass http://127.0.0.1:9091;
}
if ($device = pc) {
proxy_pass https://www.127.0.0.1.com;
}
}
未经允许不得转载:微信 美文-微信文章库-我的知识库 » 根据ua代理到不同的网站-手机端或pc端