欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

nginx判断移动端还是pc端分别转发不同地址

程序员文章站 2024-01-01 11:34:34
server { listen 80; server_name xxx.cn; location / { root /data/web/pc; if ( $http_user_agent ~ "(MIDP)|(WAP)|(UP.Browser)|(Smartphone)|(Obigo)|(Mobile)|(AU.Browser)|(wxd.Mms)|(WxdB.Brows.....

server {

        listen   80;
        server_name xxx.cn;


	 location / { 
                root /data/web/pc;
                  
       if ( $http_user_agent ~ "(MIDP)|(WAP)|(UP.Browser)|(Smartphone)|(Obigo)|(Mobile)|(AU.Browser)|(wxd.Mms)|(
WxdB.Browser)|(CLDC)|(UP.Link)|(KM.Browser)|(UCWEB)|(SEMC-Browser)|(Mini)|(Symbian)|(Palm)|(Nokia)|(Panasonic)|(MOT-)|(Sony
Ericsson)|(NEC-)|(Alcatel)|(Ericsson)|(BENQ)|(BenQ)|(Amoisonic)|(Amoi-)|(Capitel)|(PHILIPS)|(SAMSUNG)|(Lenovo)|(Mitsu)|(Mot
orola)|(SHARP)|(WAPPER)|(LG-)|(LG/)|(EG900)|(CECT)|(Compal)|(kejian)|(Bird)|(BIRD)|(G900/V1.0)|(Arima)|(CTL)|(TDG)|(Daxian)
|(DAXIAN)|(DBTEL)|(Eastcom)|(EASTCOM)|(PANTECH)|(Dopod)|(Haier)|(HAIER)|(KONKA)|(KEJIAN)|(LENOVO)|(Soutec)|(SOUTEC)|(SAGEM)
|(SEC-)|(SED-)|(EMOL-)|(INNO55)|(ZTE)|(iPhone)|(Android)|(Windows CE)|(Wget)|(Java)|(curl)|(Opera)" )
       	 {       
       	         root /data/web/mobile;
       	 }
	}
	#Images
       location ~ .*\.(ico|gif|jpg|jpeg|png|bmp|swf|apk|exe)$ {
       access_log off;
       root /data/images;
       expires      5d;

        }
    }

	server {
		
		listen 80;
		server_name xxx.com;

		 location / {
			 proxy_set_header    Host $host;
       			 proxy_set_header    X-Real-IP $remote_addr;
        		proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    			proxy_pass  http://100.100.100.100:8081;
		}
	}
}

 

本文地址:https://blog.csdn.net/z858466/article/details/106944238

上一篇:

下一篇: