我正在使用 nginx,但设置反向代理时遇到问题。
我的 nginx.conf 是默认的(没有对其进行任何更改),我的站点可用配置是:
upstream backend_hosts {
server server1.example.com
server server2.example.com
}
server {
listen 80;
location / {
proxy_set_header Host $host;
proxy_pass http://backend_hosts;
}
}
Run Code Online (Sandbox Code Playgroud)
它不起作用,它不传递主机标头。当我做这样的事情时,它会起作用:
...
proxy_set_header Host server1.exampple.com;
...
Run Code Online (Sandbox Code Playgroud)
我想做这样的事情:
proxy_set_header Host $current_upstream_server_name;
Run Code Online (Sandbox Code Playgroud) nginx ×1