美文网首页
Tomcat配置ssl

Tomcat配置ssl

作者: 早_wsm | 来源:发表于2020-07-24 16:00 被阅读0次

    下载证书

    下载证书至/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

    此文参考优秀博客:https://www.cnblogs.com/xuliangwei/p/11604272.html

    相关文章

      网友评论

          本文标题:Tomcat配置ssl

          本文链接:https://www.haomeiwen.com/subject/bkajlktx.html