tomcat 自動(dòng)跳轉(zhuǎn)到HTTPS
到conf目錄下的web.@xml。在</welcome-file-list>后面,</web-app>,也就是倒數(shù)第二段里,加上這樣一段
<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跳轉(zhuǎn)到ssl的connector去。所以還需要前往server.@xml進(jìn)行配置:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
redirectPort改成ssl的connector的端口443,重啟后便會(huì)生效。