我在我的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