1. 在Tomcat的conf/server.xml文件中,找到Connector节点,添加以下属性:

secure="true" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" disableUploadTimeout="true" acceptCount="100" scheme="https" redirectPort="8443" compression="on" compressableMimeType="text/html,text/xml,text/javascript,text/css"

  1. 在Tomcat的web.xml文件中,添加以下过滤器:
strictTransportSecurityFilter org.apache.catalina.filters.StrictTransportSecurityFilter max-age 31536000 strictTransportSecurityFilter /*
  1. 在Tomcat的conf/web.xml文件中,添加以下配置:
HTTPS only /* CONFIDENTIAL
  1. 重启Tomcat服务器,访问网站时浏览器会自动保存HSTS信息,并在以后访问时强制使用HTTPS连接
tomcat设置Strict Transport Security

原文地址: https://www.cveoy.top/t/topic/fvCQ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录