Tomcat的web服务自动跳转到https的设定

本文详细介绍了如何在Tomcat服务器上配置SSL证书以实现HTTPS安全连接。包括在web.xml中设置安全约束、生成证书密钥库及在server.xml中配置SSL连接器。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在web应用的web.xml中添加如下配置信息
    <security-constraint>
      <web-resource-collection>
        <web-resource-name>Automatic SSL Forwarding</web-resource-name>
        <url-pattern>/*</url-pattern>
      </web-resource-collection>
      <user-data-constraint>
        <transport-guarantee>
          CONFIDENTIAL
        </transport-guarantee>
      </user-data-constraint>
    </security-constraint>
配置Tomcat
    <Connector acceptCount="100" connectionTimeout="20000"
        disableUploadTimeout="true" enableLookups="false" maxHttpHeaderSize="8192"
        maxSpareThreads="75" maxThreads="150" minSpareThreads="25" port="80"
        redirectPort="8443" />

    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" acceptCount="100" clientAuth="false"
        disableUploadTimeout="true" enableLookups="false" maxThreads="150"
        scheme="https" secure="true" sslProtocol="TLS" 
        keystoreFile="C:/Users/SHOU/.keystore" keystorePass="test1234"
    />

如果想要去掉地址中的端口号8443 。讲上述tomcat配置信息中的端口号都修改为 443 即可

配置参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值