http {
include mime.types;
default_type application/octet-stream;
upstream tomcat_cluster {
server 10.10.50.157:8081 weight=3;
server 10.10.50.156:8081 weight=2;
}
sendfile on;
keepalive_timeout 65;
server {
listen 9527;
server_name 10.10.50.81;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-HOST $host:$9527; # 关键需要在此处添加端口号变量,或者直接使用端口号9527
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
absolute_redirect off;
proxy_redirect off;
location / {
proxy_pass http://tomcat_cluster;
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
请诸位大神解惑
配置改成如下:location / {
– 凉凉90 2年前proxy_pass http://tomcat_cluster;
proxy_set_header Host $host:$server_port;
}