nginx 根據header 中key值進行參數跳轉

需求:
提供一個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;
            }
        }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章