我在我的nginx配置中有這個代理傳遞。我可以通過代理傳遞根到一個地址,其餘的地址在nginx的另一個地址?
location /content {
proxy_set_header Host $proxy_host;
proxy_pass $address1;
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
}
我想proxy_pass /content
到$address1
但我想proxy_pass任何其他/content/something_else
到$address2
這可能在nginx的?
例如,如果我打http://www.example.com/content?some_other_param=value
它會被轉發到http://www.content.com
,但如果我打http://www.example.com/content/article?some_param=value
這將打擊http://www.different_content.com
如果我的答案回答了問題,可以請+1嗎?如果沒有,請告訴我缺少什麼。謝謝。 – cnst