Tomcat 强制重定向HTTPS

在配置好 Tomcat SSL 证书的前提下,将 HTTP 重定向 HTTPS

vi /path/to/tomcat/conf/web.xml

<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>

:wq

重启 Tomcat