1
我有兩個監聽器80和777.端口80充當反向代理。而端口777做了一些額外的東西,並希望重定向到端口80.如何重定向到Nginx中的不同端口?我與重寫嘗試,但後來想通了,它僅用於路徑的變化將請求重定向到不同的監聽器nginx
###
server{
listen 80;
server_name _;
location/{
proxy_pass "http://upstream0;#" is included since links are not allowed in the post
}
}
server{
listen 777;
server_name _;
#doing some other extra stuf
//Want to redirect to port 80 under some condition
}
這可能嗎?
感謝
proxy_pass在if條件中是不允許的,您應該使用location/{proxy_pass http:// $ host:80; } – 2014-04-26 15:47:14
根據上面的鏈接文檔,proxy_pass指令允許的上下文之一是「if in location」,更新示例以明確指出 – cobaco 2014-04-29 17:30:44
這也不起作用,它在文檔中不可用,我試過了它之前。 – 2014-04-29 20:51:56