proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# 设置代理的协议头 https,与tomcat中的配置(protocolHeader="x-forwarded-proto")配合使用,tomcat 需要添加的配置见后面
proxy_set_header X-Forwarded-port $server_port;
# 设置代理的端口,与tomcat中配置(portHeader="x-forwarded-port")配合使用,因为在代码中想要使用request.getServerPort() 获取到8888,如果不配此项导致获取到的端口为443(https默认的端口),同时request.getRequestURL() 获取到url地址可能是不含有端口的
<Valve className="org.apache.catalina.valves.RemoteIpValve"
remoteIpHeader="X-Forwarded-For"
protocolHeader="X-Forwarded-Proto"
protocolHeaderHttpsValue="https"
port-header="X-Forwarded-Port"/>
server:
tomcat:
remote-ip-header: X-Forwarded-For
protocol-header: X-Forwarded-Proto
protocol-header-https-value: https
port-header: X-Forwarded-Port