第一步:修改server.xml配置如下:
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" URIEncoding="UTF-8" />
<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
keystoreFile="cert/server.jks"
keystorePass="Ft2*c7XVZkur#MvZ"
clientAuth="false" sslProtocol="TLS" ></Connector>
<Connector port="8009" protocol="AJP/1.3" redirectPort="443" />
第二部:开放443端口:
打开防火墙设置,选高级设置,入站规则,新建端口,443,允许通行。
第三部:然后设置强制https跳转,方法如下:
打开tomcat/conf/web.xml中的</welcome-file-list>后面增加以下内容,实现强制跳转:
<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>
重启tomcat。