Description
Claude helped me here, please review for bad assumptions before proceeding.
dotCMS exposes common Tomcat configuration settings as environment variables (CMS_* prefix) for conf/server.xml and conf/context.xml, allowing operators to tune runtime behavior without rebuilding the image. conf/web.xml and WEB-INF/web.xml have no equivalent support — settings like session timeout and security header parameters are hardcoded.
File inventory
| File |
Container path |
Source |
Native ${ENV_VAR} support |
conf/web.xml |
/srv/dotserver/tomcat-*/conf/web.xml |
Apache Tomcat distribution (no custom override in repo) |
✅ Yes — same mechanism as server.xml |
WEB-INF/web.xml |
/srv/dotserver/tomcat-*/webapps/ROOT/WEB-INF/web.xml |
dotCMS/src/main/webapp/WEB-INF/web.xml |
❌ No — Servlet spec does not define variable interpolation |
conf/web.xml — implementation path (straightforward)
Tomcat's global conf/web.xml uses the same IntrospectionUtils variable substitution as server.xml and context.xml. The repo already has an override mechanism:
- Files in
dotCMS/src/main/resources/container/tomcat9/conf/ replace Tomcat distribution defaults at build time.
- Each file is registered as a
<configfile> in the Cargo Maven plugin section of dotCMS/pom.xml.
Adding conf/web.xml requires:
- Creating
dotCMS/src/main/resources/container/tomcat9/conf/web.xml (based on Tomcat 9.x default)
- Replacing selected hardcoded values with
${CMS_*:-default} syntax
- Adding a
<configfile> entry in dotCMS/pom.xml after the existing context.xml entry (~line 2153)
WEB-INF/web.xml — constraint and options
The Servlet specification does not define variable interpolation for WEB-INF/web.xml. Tomcat's IntrospectionUtils resolver is not invoked for this file — ${MY_VAR} is treated as a literal string.
Initially targeted settings (in scope for this issue):
<filter>
<filter-name>HttpHeaderSecurityFilter</filter-name>
<filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
<async-supported>true</async-supported>
<init-param>
<param-name>hstsMaxAgeSeconds</param-name>
<param-value>3600</param-value>
</init-param>
<init-param>
<param-name>hstsIncludeSubDomains</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>antiClickJackingOption</param-name>
<param-value>SAMEORIGIN</param-value>
</init-param>
</filter>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
| Setting |
Suggested env var |
Current value |
hstsMaxAgeSeconds |
${CMS_HSTS_MAX_AGE_SECONDS:-3600} |
3600 |
hstsIncludeSubDomains |
${CMS_HSTS_INCLUDE_SUBDOMAINS:-true} |
true |
antiClickJackingOption |
${CMS_ANTI_CLICK_JACKING_OPTION:-SAMEORIGIN} |
SAMEORIGIN |
session-timeout |
${CMS_SESSION_TIMEOUT:-30} |
30 |
Workaround options for WEB-INF/web.xml (developer decision required):
| Option |
Approach |
Notes |
| A |
Startup script (envsubst) rewrites WEB-INF/web.xml at container startup |
No code changes; requires file writable at runtime |
| B |
Subclass org.apache.catalina.filters.HttpHeaderSecurityFilter, override init() to check env vars |
Clean; requires maintenance per Tomcat upgrade |
| C |
Move session-timeout to conf/web.xml (native support); handle filter settings separately |
Practical quick win for session timeout |
References
Acceptance Criteria
WEB-INF/web.xml — initial settings
conf/web.xml (optional stretch goal)
Both
Description
Claude helped me here, please review for bad assumptions before proceeding.
dotCMS exposes common Tomcat configuration settings as environment variables (
CMS_*prefix) forconf/server.xmlandconf/context.xml, allowing operators to tune runtime behavior without rebuilding the image.conf/web.xmlandWEB-INF/web.xmlhave no equivalent support — settings like session timeout and security header parameters are hardcoded.File inventory
${ENV_VAR}supportconf/web.xml/srv/dotserver/tomcat-*/conf/web.xmlserver.xmlWEB-INF/web.xml/srv/dotserver/tomcat-*/webapps/ROOT/WEB-INF/web.xmldotCMS/src/main/webapp/WEB-INF/web.xmlconf/web.xml— implementation path (straightforward)Tomcat's global
conf/web.xmluses the sameIntrospectionUtilsvariable substitution asserver.xmlandcontext.xml. The repo already has an override mechanism:dotCMS/src/main/resources/container/tomcat9/conf/replace Tomcat distribution defaults at build time.<configfile>in the Cargo Maven plugin section ofdotCMS/pom.xml.Adding
conf/web.xmlrequires:dotCMS/src/main/resources/container/tomcat9/conf/web.xml(based on Tomcat 9.x default)${CMS_*:-default}syntax<configfile>entry indotCMS/pom.xmlafter the existingcontext.xmlentry (~line 2153)WEB-INF/web.xml— constraint and optionsThe Servlet specification does not define variable interpolation for
WEB-INF/web.xml. Tomcat'sIntrospectionUtilsresolver is not invoked for this file —${MY_VAR}is treated as a literal string.Initially targeted settings (in scope for this issue):
hstsMaxAgeSeconds${CMS_HSTS_MAX_AGE_SECONDS:-3600}3600hstsIncludeSubDomains${CMS_HSTS_INCLUDE_SUBDOMAINS:-true}trueantiClickJackingOption${CMS_ANTI_CLICK_JACKING_OPTION:-SAMEORIGIN}SAMEORIGINsession-timeout${CMS_SESSION_TIMEOUT:-30}30Workaround options for
WEB-INF/web.xml(developer decision required):envsubst) rewritesWEB-INF/web.xmlat container startuporg.apache.catalina.filters.HttpHeaderSecurityFilter, overrideinit()to check env varssession-timeouttoconf/web.xml(native support); handle filter settings separatelyReferences
dotCMS/src/main/resources/container/tomcat9/conf/dotCMS/pom.xml~lines 2148–2155dotCMS/src/main/docker/original/DockerfiledotCMS/src/main/webapp/WEB-INF/web.xmlAcceptance Criteria
WEB-INF/web.xml— initial settingshstsMaxAgeSecondsconfigurable viaCMS_HSTS_MAX_AGE_SECONDS(default:3600)hstsIncludeSubDomainsconfigurable viaCMS_HSTS_INCLUDE_SUBDOMAINS(default:true)antiClickJackingOptionconfigurable viaCMS_ANTI_CLICK_JACKING_OPTION(default:SAMEORIGIN)session-timeoutconfigurable viaCMS_SESSION_TIMEOUT(default:30)conf/web.xml(optional stretch goal)dotCMS/src/main/resources/container/tomcat9/conf/web.xmlcreated, based on Tomcat 9.x defaultdotCMS/pom.xmlCargo configfiles alongsideserver.xmlandcontext.xmlBoth
CMS_prefix conventionCMS_*env var behavior