zoukankan      html  css  js  c++  java
  • 【nginx】简易接口转发实现

        set $name_ver "${http_app_name}_${http_app_ver}";
        if ($name_ver = "xcx_110") {
            rewrite (.*) /REJUMP/$1 break;
        }
    
        location /REJUMP{
            rewrite ^/REJUMP/(.*) $1 break;
            internal;
            proxy_pass         http://192.168.1.10;
            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_connect_timeout 20;
            proxy_send_timeout 30;
            proxy_read_timeout 30;
            proxy_next_upstream http_502 http_504 error timeout invalid_header;
        }
    
        #location ~ .*.(php|php5)?$
        #{
        #    fastcgi_pass  php56;
        #    fastcgi_index index.php;
        #    include fcgi.conf;
        #}
    
        location / {
            if (!-e $request_filename) {
                rewrite  ^(.*)$  /index.php?s=$1  last;   break;
            }
            fastcgi_pass  php56;
            fastcgi_index index.php;
            include fcgi.conf;
        }
    

    1、通过header信息,在nginx获取http_$headerkey

    2、根据版本号判断,先添加一个标识/JUMP

    3、location匹配,去掉添加的标识,请求转发到其他服务器

    4、主意:屏蔽的代码,因为匹配优先级比/JUMP高

      

    得意时做事,失意时读书
  • 相关阅读:
    io流(input output)
    Mybatis实例
    框架(mybatis概念及环境搭建
    easyui试做窗口.不完整
    while (rs.next()) 与 if(rs.next())的区别
    json名词解释
    jQuery2
    去除inline-block元素间间距的N种方法
    jQuery的deferred对象详解
    js基础知识集锦
  • 原文地址:https://www.cnblogs.com/lanse1993/p/12837257.html
Copyright © 2011-2022 走看看