1.在tomcat的conf/server.xml 中配置
<Connector port="443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="D:\keystore\zhihu.org.cn\Tomcat\zhihu.org.cn.jks" keystorePass="123456"
/>
2. 将 redirectPort 的端口号都指向443
<Connector connectionTimeout="20000" port="9002" protocol="HTTP/1.1" redirectPort="443"/> <Connector port="8009" protocol="AJP/1.3" redirectPort="443"/>
3.在conf/web.xml里最下面配置
<security-constraint><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>
4. 重启tomcat,然后再打浏览器里打开
zhihu.org.cn 会自动跳转到 https://zhihu.org.cn (会显示404)
打开 默认应用 https://zhihu.org.cn/examples/ 可看到正常效果