nginx 监听的服务器的9000 端口,转的443 到tomcat 中,但是在java web jsp中获取的端口却还是443.
location /xxx{
proxy_pass https://localhost:9020;
client_max_body_size 1000m;
proxy_redirect off;
# 此处header 需要增加$server_port 即可
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header User-Agent $http_user_agent;
proxy_set_header header_userid $http_header_userid;
proxy_set_header user_type $http_user_type;
#防止网页被Frame
add_header X-Frame-Options SAMEORIGIN;
}
修改:
proxy_set_header Host $host:$server_port;
此时再看jsp中的request.getServerPort()
就是当前监听的了。
转载请注明出处: https://chrunlee.cn/article/nginx-java-web-port.html