需求:
提供一個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;
}
}