server {
listen 80;
server_name xxx.com;
location = / {
if ($http_user_agent ~ "(Windows\sNT)|(FireFox)|(Macintosh)|(Windows\s95)|(Windows\s98)"){
set $ismob 1;
proxy_pass http://test.com;
break;
}
if ($http_user_agent ~ "(iPhone)|(Opera\sMini)|(MIDP-[0-9])|(MIDP[0-9])|(SymbianOS)|(Symbian\sOS)|(Windows\sCE)|(BlackBerry)|(^SonyEricsson)|(^Nokia)|(^NOKIA)|(UP\.Link)|(^SAMSUNG)|(^MOT-)|(^DoCoMo)|(UP\.Browser)|(^Mitsu)|(UCWEB)|(MAUI)|(^Palm)|(^Blazer)|(^BIRD\.E868)"){
set $ismob 2;
}
if ($http_accept ~ "(/vnd\.wap)"){
set $ismob 2;
}
if ($http_x_up_bearer_type ~ "(.+)"){
set $ismob 2;
}
if ($http_x_source_id ~ "(.+)"){
set $ismob 2;
}
if ($http_encryptmdn ~ "(.+)"){
set $ismob 2;
}
if ($http_via ~ "(wap.+WISG)"){
set $ismob 2;
}
if ($ismob = 2){
rewrite "^.*$" http://wap.test.com/;
break;
}
proxy_pass http://test.com;
}
………
[/code]