php是最好的语言

利用反向代理实现客户端设备转发

        利用$http_user_agent实现区别客户端访问的设备进行转发,下面是根据浏览器类型进行转发:

        location / {

            if ($http_user_agent ~* "MSIE")//IE

            {

                proxy_pass http://one_pools;

            }

            if ($http_user_agent ~* "Chrome")//谷歌

            {

                proxy_pass http://two_pools;

            }

            proxy_pass http://default_pools;//其他客户端

            include proxy.conf;//一系列其他配置,之前有

        }

        区分移动端:

        

             location / {

            if ($http_user_agent ~* "android")//安卓

            {

                proxy_pass http://one_pools;

            }

            if ($http_user_agent ~* "iphone")//苹果

            {

                proxy_pass http://two_pools;

            }

            proxy_pass http://default_pools;//其他客户端

            include proxy.conf;//一系列其他配置,之前有

        }

        也可以根据扩展名实现转发实现动静分离

        location ~ .*.(gif|jgp|png|css|js)

        {

            proxy_pass http://static_pools;

            include proxy.conf

        }

        

        location ~ .*.(php|php3|php5)

        {

            proxy_pass http://dynamic_pools;

            include proxy.conf

        }


作者:xTao 分类:LNMP 浏览:2350 评论:0