Linux

Tomcat 9 needs the WorkingDirectory specified in the Systemd service in order to work. Without it, the service will start but never completely load!

To use, put this is in /etc/systemd/system/tomcat.service and install the service as usual.


[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
After=systemd-user-sessions.service
After=network-online.target

[Service]
User=tomcat
Group=tomcat
Type=forking
WorkingDirectory=/app/XXX/bin
ExecStart=/bin/bash /app/XXX/bin/catalina.sh start
ExecStop=/bin/bash /app/XXX/bin/catalina.sh stop

[Install]
WantedBy=multi-user.target

Enabling HSTS and SSL Redirection for Tomcat 9.x

This document details how to enable HSTS and SSL redirection (by default port 80 to 443) on a Tomcat 9.x instance. This will not work on 8.x versions of Tomcat because they changed some of the keywords for some reason.

Enable HSTS

Enabling HSTS (to include maxAgeSeconds = 31536000, includeSubDomains, and preload) requires two modifications of the Tomcat’s conf/web.xml file:
1. First, to enable HSTS support, Continue Reading