首页 > 代码库 > tomcat从 http转成https,并且去掉端口号

tomcat从 http转成https,并且去掉端口号

<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/> 

改成

<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" URIEncoding="UTF-8"/> 

 

重启

这样用户也可以去掉端口同时访问http和https了

 

另: 强制https访问

 在tomcat\conf\web.xml中的</welcome-file-list>后面加上这样一段: 

<login-config>  
    <!-- Authorization setting for SSL -->  
    <auth-method>CLIENT-CERT</auth-method>  
    <realm-name>Client Cert Users-only Area</realm-name>  
</login-config>  
<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> 

完成以上步骤后,在浏览器中输入http的访问地址也会自动转换为https了

 

tomcat从 http转成https,并且去掉端口号