Nginx配置proxy_pass轉發的/路徑問題
在nginx中配置proxy_pass時,如果是按照^~匹配路徑時,或者直接/*匹配時,要注意proxy_pass後的url最後的/,當加上了/,相當於是絕對根路徑,則nginx不會把location中匹配的路徑代理走;如果沒有/,則會把匹配的路徑部分也給代理走。
location /registry {
proxy_pass http://localhost:8001/;
access_log "logs/registry.log";
}
代理前的訪問地址:http://localhost:8001
代理後的訪問地址:http://localhost:8087/registry
我nginx的端口是8087