tomcat http 强制使用 https 访问
原创 kill_bug 发表于:2018-02-27 16:32:31
  阅读 :140   收藏   编辑

编辑tomcat目录下的conf\web.xml文件,在最后web-app标签内新增如下:

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

如图:

浏览器访问:http://localhost:8080
将自动跳转:https://localhost:8443