Problem Description:
Use interceptors Intercepter intercept requests in SPRINGMVC, use httpservletrequest in interceptors to get the requested path intercepted (without the path of the request parameter), but the problem is that the path of the requested HTTPS protocol, The program gets the HTTP protocol, resulting in an error in the logic behind it.
Cause Analysis:
Due to the project design to SSO single sign-on function, the use of the Nginx proxy, the entire project is deployed using Nginx+tomcat, so Tomcat received requests from nginx forward, so this problem is caused by nginx configuration problem
Workaround:
1. Add Proxy_set_header x-forwarded-schema $schema at the nginx configuration location; This way, the real path can be obtained by Servlet.getheader ("X-forwarded-schema").
2. In Tomcat Server.xml, add the following
<engine name= "Catalina" defaulthost= "localhost" >
<valve classname= " Org.apache.catalina.valves.RemoteIpValve "
remoteipheader=" x-forwarded-for "
protocolheader=" X-forwarded-proto "
protocolheaderhttpsvalue=" https "/>
...
3. If the Request.getschema () method is used in multiple places in the code, you can modify the tomcat configuration directly to avoid multiple modifications
<connector port= "443" maxhttpheadersize= "8192" maxthreads= "enablelookups=" "
false" Disableuploadtimeout= "true"
acceptcount= "scheme=" "https" secure= "true"
sslenabled= "true"
Sslcertificatefile= "${CATALINA.BASE}/CONF/LOCALHOST.CRT"
sslcertificatekeyfile= "${catalina.base}/conf/ Localhost.key "/>
If Nginx adds SSL authentication and Tomcat does not add SSL authentication, configure Scheme= "https" secure= "true" one line
If Tomcat also adds SSL authentication, add the configuration
Sslenabled= "true"
sslcertificatefile= "${catalina.base}/conf/localhost.crt"
sslcertificatekeyfile= "${ Catalina.base}/conf/localhost.key "
Can