tomcat 自动跳转到HTTPS
到conf目录下的web.@xml。在</welcome-file-list>后面,</web-app>,也就是倒数第二段里,加上这样一段
<login-config>
<!-- Authorization setting for SSL -->
<auth-method>CLIENT-CERT</auth-method>
<realm-name>Client Cert Users-only Area</realm-name>
</login-config>
<security-constraint>
<!-- Authorization setting for SSL -->
<web-resource-collection>
<web-resource-name>SSL</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
这步目的是让非ssl的connector跳转到ssl的connector去。所以还需要前往server.@xml进行配置:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
redirectPort改成ssl的connector的端口443,重启后便会生效。