0
我要代理請求這樣的: http://myproxy.com/api/folder1/result1?test=1
,http://myproxy.com/api/folder3447/something?var=one
Nginx的proxy_pass所有的URL參數
等效目的地:http://destination.com/folder1/result1?test=1
和http://destination.com/folder3447/something?var=one
,實際上只有域的變化和所有子文件夾,而params將被保留
在配置中的位置如下所示:
location ~* ^/api/(.*) {
proxy_pass http://destination.com/$1$is_args$args;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header Host $http_host;
}