upstream test_server {
server 127.0.0.1:8086 max_fails=3 fail_timeout=10s;
}
server {
listen 80;
server_name xxx.example.com;
charset utf-8;
access_log off;
location / {
proxy_redirect http://test/ http://$host:$server_port;
proxy_pass http://test_server;
}
}
浏览器URL直接就变成http://test_server了,如果使用 proxy_pass http://127.0.0.1:8086;就能正常访问