页面树结构
转至元数据结尾
转至元数据起始


HTTP重定向到 HTTPS

① 打开 tomcat 的 conf\server.xml 文件。将 http 端口配置中重定向的端口设置 https 的端口。即将 redirectPort="8443" 的值改为 https 的端口

② 设置 http 强制跳转到 https

修改 tomcat 的 conf\web.xml 文件,在末尾添加:

需要添加的配置项参考如下:

    <!-- http 强制转 https 配置 -->
    <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 请求类型 配置 -->
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>filter-http-method</web-resource-name>
            <url-pattern>/*</url-pattern>
            <http-method>OPTIONS</http-method>
            <http-method>PUT</http-method>
            <http-method>DELETE</http-method>
            <http-method>OPTIONS</http-method>
            <http-method>HEAD</http-method>
        </web-resource-collection>
        <auth-constraint></auth-constraint>
    </security-constraint>
  • 无标签