需求: 提供一个POST接口地址给第三方, 我方根据header头中source=5进行转发不同地址。 获取header中的key方法: $http_KEY Nginx location配置如下:

        location /test/ {
            if ($http_source = "5"){
                proxy_pass http://10.83.74.164:9201;
                rewrite ^/test/(.*) /$1 break;
            }
            if ($http_source != "5"){
                proxy_pass http://10.83.74.164:9091;
                rewrite ^/test/(.*) /$1 break;
            }
        }