zoukankan      html  css  js  c++  java
  • nginx动静分离

    1.最好的情况是在业务上做动静分离,如果业务没有做此功能,nginx也可以实现

    2.方式1:利用URL匹配

    访问地址:http://www.vijay.com/status

    3.方式2:利用扩展名匹配

    3.方式3:利用rewrite中的if(此方式还可以用于判断浏览器,如判断浏览器是IE6,则转发提示页面,提示浏览器版本低,请升级)

    4.根据user客户端类型(win,mac,ios,安卓)进行请求分配:(关键参数:proxy_set_header http_user_agent $http_user_agent;)

            #样式
            location ~ .*.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|font|ttf)$ {
                    if ($http_user_agent ~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)){
                            root /usr/local/nginx/html/proxy_mobile;
                    }
                    root /usr/local/nginx/html/dist;
            }
    
            #后台数据接口
            location ~* /(ipagent)/ {
                    proxy_pass http://backend;
            }
    
    
            #首页
            location  / {
                #root   /usr/local/nginx/html/;
                #index  index.html index.htm index.html;
                if ($http_user_agent ~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)){
    
                            #try_files $uri $uri/proxy_mobile/ /index.html;
                            #index  index.html index.htm;
                            root /usr/local/nginx/html/proxy_mobile;
                            #index  index.html index.htm;
                    }
    
    
                try_files $uri $uri/dist /index.html;
           }
  • 相关阅读:
    codevs 3971 航班
    2015山东信息学夏令营 Day4T3 生产
    2015山东信息学夏令营 Day5T3 路径
    Tyvj 1221 微子危机——战略
    清北学堂模拟赛 求和
    NOIP2012同余方程
    NOIP2009 Hankson的趣味题
    bzoj1441 MIN
    国家集训队论文分类
    贪心 + DFS
  • 原文地址:https://www.cnblogs.com/vijayfly/p/5486367.html
Copyright © 2011-2022 走看看