下载证书
下载证书至/mnt
目录下
主要配置文件:
[root@tomcat ~]# vim /mnt/tomcat/conf/server.xml
<!--1.修改Host name为www.a.com -->
<Host name="www.a.com" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!--2.修改redirectPort="8443"为redirectPort="443"-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
<!--3.增加如下内容-->
<Connector port="443"
protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150"
SSLEnabled="true"
scheme="https"
secure="true"
keystoreFile="/mnt/ssl.pfx"
keystoreType="PKCS12"
keystorePass="123456"
clientAuth="false"
SSLProtocol="TLSv1+TLSv1.1+TLSv1.2"
ciphers="TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA256"/>
重启tomcat,访问页面验证
配置强制跳转
在</welcome-file-list>后面加入以下这段话
<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>
重启即可实现强制跳转https
网友评论