How to enable HTTP Strict Transport Security (HSTS) for Data Center Security(DCS, DCS:SA) with Tomcat 9.0 on port 443 and 8443.
Release: DCS, DCS:SA 6.9.0, 6.9.1
Component: Tomcat 9.0
More information can be found here:
To enable HSTS in Tomcat 9.0, follow below steps:
Modify/Update "httpHeaderSecurity" filter within Tomcat web.xml with following values:
<filter>
<filter-name>httpHeaderSecurity</filter-name>
<filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
<async-supported>true</async-supported>
<init-param>
<param-name>hstsEnabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>hstsMaxAgeSeconds</param-name>
<param-value>31536000</param-value>
</init-param>
<init-param>
<param-name>hstsIncludeSubDomains</param-name>
<param-value>true</param-value>
</init-param>
</filter>
Uncomment the below section:
<filter-mapping>
<filter-name>httpHeaderSecurity</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
The above filter values represents:
hstsEnabled (true) : HTTP Strict Transport Security (HSTS) header to be added to the response.
hstsMaxAgeSeconds (31536000) : The one year age value that should be used in the HSTS header.
hstsIncludeSubDomains (true) : The includeSubDomains parameter to be included in the HSTS header.
More information@ https://tomcat.apache.org/tomcat-9.0-doc/config/filter.html
Following value is getting set as a part of response header.
"Strict-Transport-Security: max-age=31536000;includeSubDomains"
Note: