Recently in a project, the use of enterprise, the structure of the use of Nginx +tomcat cluster, and Nginx configuration Ssl,tomcat no SSL, the project uses the HTTPS protocol, but in the debugging menu related functions found error, error information as follows:
After debugging the code inside the Dofilter, found that: the URL entered in the browser is
HTTPS://shaidh.dhwrwi.com/dheu/syuu.do But interrupt point debug Request.getrequesturl () output is always
http://shaidh.dhwrwi.com/dheu/syuu.do
Read some information and found a solution:
The solution is simple, just need to configure Nginx and Tomcat separately, instead of changing the program.
Configure the Nginx forwarding options:
Locate the vhost.conf in the Conf folder of the Nginx installation directory,
In the Proxy_set_header Host $host; Add a row below
Proxy_set_header X-forwarded-proto $scheme;
Configure a Valve under the Engine module of the Tomcat Server.xml:
<Valve classname="Org.apache.catalina.valves.RemoteIpValve"
remoteipheader="x-forwarded-for"
protocolheader="X-forwarded-proto"
protocolheaderhttpsvalue=
"https"
/>
The X-forwarded-proto is configured to correctly identify whether the actual user is sending an HTTP or HTTPS protocol.
Then look at Request.getrequesturl () and you will see that the output is HTTPS
Nginx ssl+tomcat cluster, cannot get HTTPS correct protocol