tomcat配置http和https访问

设置使tomcat既支持http访问,也支持https访问。需要在server.xml中进行设置
<!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"/>
    -->

将注释去掉,同时添加证书路径和证书私钥
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"
               keystoreFile="e:\cert\tomcat.keystore"   keystorePass="p.tt.jubao110.com"/>

保存后,重启tomcat即可。

将tomcat设置成只支持https访问模式,需要在web.xml配置文件中进行处理,
    完成上面的配置后,打开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>
保存,重启tomcat,设置完成

猜你喜欢

转载自963630220-qq-com.iteye.com/blog/1678554
今日推荐