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

时间:2022-05-27 04:42:11

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

改成

<Connector port="" protocol="HTTP/1.1" connectionTimeout="" redirectPort="" 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了