Skip to content

Commit

Permalink
- ADD: Added Tomcat configuration settings to remove server information.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-raubach committed Jan 16, 2024
1 parent 1ab6aed commit f2fb61e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ FROM tomcat:10.1-jdk11

LABEL maintainer="[email protected]"

RUN apt-get update && \
apt-get --yes --force-yes install unzip zip && \
# Obscuring server info
cd ${CATALINA_HOME}/lib && \
mkdir -p org/apache/catalina/util/ && \
unzip -j catalina.jar org/apache/catalina/util/ServerInfo.properties -d org/apache/catalina/util/ && \
sed -i 's/server.info=.*/server.info=Apache Tomcat/g' org/apache/catalina/util/ServerInfo.properties && \
zip -ur catalina.jar org/apache/catalina/util/ServerInfo.properties && \
rm -rf org && cd ${CATALINA_HOME} && \
# Add a default error page mapping to hide the exception message
sed -i 's/<\/web-app>/ <error-page>\n <exception-type>java.lang.Throwable<\/exception-type>\n <location>\/dev\/null<\/location>\n <\/error-page>\n<\/web-app>/g' conf/web.xml && \
sed -i 's/<\/Host>/ <Valve className="org.apache.catalina.valves.ErrorReportValve" showReport="false" showServerInfo="false" \/>\n <\/Host>/g' conf/server.xml

RUN mkdir -p /usr/local/tomcat/webapps && \
rm -rf /usr/local/tomcat/webapps/ROOT

Expand Down

0 comments on commit f2fb61e

Please sign in to comment.