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;
           }
  • 相关阅读:
    文件合并
    排序
    canvas 的cliprect()实现画布剪切DEMO
    SurfaceViewDemo
    View实现事件监听DEMO(文本跟随触屏事件)
    android progressBar和seekBar的小DEMO
    Android DrawerLayoutDemo
    Fragment和FragmentActivity使用Demo
    SharedPreferences DEMO
    android中sharedPreferences的用法
  • 原文地址:https://www.cnblogs.com/vijayfly/p/5486367.html
Copyright © 2011-2022 走看看