Tomcat http跳转https

先配置 web.xml(路径 tomcat的安装路径下 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>

然后在修改conf\server.xml 配置

<!--第一个端口配置的事http协议的端口:8080 通过redirectPort指定服务器正在处理http请求时收到了一个SSL传输请求后重定向的端口号即https协议的端口号443-->
<Connector port="8080"  protocol="HTTP/1.1"  connectionTimeout="20000"   redirectPort="443"  URIEncoding="UTF-8" />
<!--第二个端口号即 https协议的端口号:443 这里要修改SSLEnabled 为true 确保https协议开通,同时把https证书指向和密码输入-->
<Connector port="443"  protocol="org.apache.coyote.http11.Http11Protocol"  
    maxThreads="150" SSLEnabled="true" scheme="https"  secure="true"  
    keystoreFile="C:\23\tomcat.keystore"  keystorePass="123456"   
    clientAuth="false" sslProtocol="TLS" URIEncoding="UTF-8" />
    

<!--如果使用AJP处理,同样使用端口跳转到https443-->
<Connector port="8009" protocol="AJP/1.3" redirectPort="443" />


猜你喜欢

转载自blog.51cto.com/11728495/2512725
今日推荐