This topic will talk about some simple steps that can be taken to secure information within Tomcat. The two configuration we will look at are httpOnly, custom 404 and 500 error messages pages.
- Tomcat 6.5 and later has this option turned on automatically. To ensure that it’s working, adding the configuration in is still a good idea. This can be accomplished by editing the context.xml file located in the $CATALINA_BASE\conf folder (By default $CATALINA_BASE will be in a directory similar to C:\Program Files\Apache Software Foundation\Tomcat 7.0\).
- <Context> will be the first line that is not commented out. Edit this line so that it looks like <Context path="/idashboards" useHttpOnly="true">
- Save the file.
- Restart Tomcat.
Custom 404 and 500 Error Messages
This will create a redirection page so that if the application is down or the user types in the wrong address the user will be forwarded to a page of your design. This helps secure the information that can be accessed from the error messages.
- Locate the $CATALINA_BASE\webapps\idashboards\WEB-INF\web.xml file. (By default $CATALINA_BASE will be in a directory similar to C:\Program Files\Apache Software Foundation\Tomcat 7.0\).
- Go to the very bottom of the file. Locate the following:
- Below this section add the following:
- Create a folder call 'errors' in the $CATALINA_BASE\webapps\idashboards directory.
- Within that folder you will need to create the two html pages from above, '404_Error.html' and '500_Error.html':
- **Sample HTML**
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<div style="text-align: center;">
You have reached this page in error. Please contact your iDashboards Administrator for assistance.<br>
- Copy contents and past into the 500_Error.html>
- Change 404 (<h1>ERROR 404</h1>) to 500 (<h1>ERROR 500</h1>)
- Save both files.
- Repeat these steps in the 'idbalerts' directory, as necessary.
- Restart Tomcat
Securing Tomcat "Root" Directory
For this we will be using some of the same methods but instead of pointing to the 404 and 500 pages we are going to redirect all traffic to iDashboards.
<meta http-equiv="refresh" content="0;URL=idashboards/index.jsp">
<display-name>Welcome to Tomcat</display-name>
Welcome to Tomcat
- Delete everything except the WEB-INF directory under ROOT.
- Create a file called "index.html" in the ROOT directory.
- Copy the following HTML into index.html. This will redirect anyone that lands in the ROOT directory to iDashboards.
- Go into the web.xml located in $CATALINA_BASE\ROOT\WEB-INF.
- Locate the Welcome text.
- Now following the above text add.
- Restart Tomcat service
- Tomcat 6.0 and later
- X Platform
- Enterprise Suite