We use Tomcat quite a bit on the Unidata Science Gateway (USG) in a few different capacities via the Unidata Tomcat Docker container:
This document is a loose collection of notes concerning the use of Tomcat on the USG.
In order to get redirection to work in Tomcat (e.g., thredds-aws.unidata.ucar.edu -> tds-nexrad.scigw.unidata.ucar.edu), there are a few details that have to be taken into account in keystore.jks
and server.xml
. First, the valid certificates for the old and new URLs must be present in the .jks
keystore file and referenced in server.xml
in roughly the following manner (I've omitted a number of Connector
element details for the sake of clarity).
<Connector port="8443"
defaultSSLHostConfigName="_default_">
<SSLHostConfig honorCipherOrder="true"
hostName="_default_"
disableSessionTickets="true">
<Certificate certificateKeystoreFile="${catalina.base}/conf/keystore.jks"
certificateKeystorePassword="xxx"
certificateKeyAlias="tds-nexrad.scigw.unidata.ucar.edu"/>
</SSLHostConfig>
<SSLHostConfig honorCipherOrder="true"
hostName="thredds-aws.unidata.ucar.edu"
disableSessionTickets="true">
<Certificate certificateKeystoreFile="${catalina.base}/conf/keystore.jks"
certificateKeystorePassword="xxx"
certificateKeyAlias="thredds-aws.unidata.ucar.edu"/>
</SSLHostConfig>
</Connector>
Additionally, you'll need to augment the Engine
element with the old and new host as well as localhost
and the RewriteValve
in the following manner (again omitting some details, e.g., logging for the sake of clarity):
<Engine name="Catalina" defaultHost="localhost">
<Host name="thredds-aws.unidata.ucar.edu" appBase="webapps" createDirs="false"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
</Host>
<Host name="tds-nexrad.scigw.unidata.ucar.edu" appBase="webapps" createDirs="false"
unpackWARs="true" autoDeploy="true">
</Host>
<Host name="localhost" appBase="webapps" createDirs="false"
unpackWARs="true" autoDeploy="true">
</Host>
</Engine>
Finally, you will need a rewrite.config
file that is co-located to the server.xml
:
RewriteCond %{HTTP_HOST} ^thredds-aws.unidata.ucar.edu$
RewriteRule ^/(.*)$ https://tds-nexrad.scigw.unidata.ucar.edu/$1 [R=301,L]