Tomcat 配置 http 跳转为 https

编辑tomcat配置文件server.xml

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />

修改参数8443为443

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="443" />
<Connector port="8009" enableLookups="false" protocol="AJP/1.3" redirectPort="8443" />

同样修改参数8443为443

<Connector port="8009" enableLookups="false" protocol="AJP/1.3" redirectPort="443" />

编辑tomcat配置文件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>

重启tomcat

上述配置完成后,重启tomcat。IE地址栏中可以直接输入地址 “http://” 会自动跳转成为 “https://”