This is configuration to setup Apache 2.4.41 as reverse proxy for Tomcat 9.0 on Ubuntu 22.
- Install mod-jk
sudo apt install libapache2-mod-jk - Setup workers.properties – Open if exists or create a file workers.properties in /etc/apache2 and paste the following:
# Define 1 real worker using ajp13worker.list=worker1# Set properties for worker (ajp13) - use of ip address apparently this solved some problemsworker.worker1.type=ajp13worker.worker1.host=127.0.0.1worker.worker1.port=8009 - Edit jk.conf to tell Apache how to find Tomcat, I used /etc/apache2/mods-available/httpd-jk.conf (Or /etc/apache2/mods-available/jk.conf, if it exits).In this file, change the JkWorkersFile property to the path where you created workers.properties (OR wherever you have your worker.properties)
JkWorkersFile /etc/apache2/workers.properties - Open /etc/apache2/sites-enabled/000-default.conf and
- Update ServerAdmin to whatever email you like to use [Optional]
- add the JkMount line in your VirtualHost configuration, inside <VirtualHost *:80> tag
JkMount /* worker1
- Make Tomcat 9.0 Server.xml changes, like so:
- Comment connectors with 80, 8080 and 443, uncomment/enable “ajp/1.3” Connector with port 8009 [or whatever port you like, but you will need to use that in worker.properties]
- Add property secretRequired=”false” in ajp connector element, use ip address in element 127.0.0.1 [This applies to newer versions of Tomcat only]
- Add Include in apache2.conf
Include /etc/apache2/mods-available/httpd-jk.conf - Add JkStatus and JkManager entries in worker.properties
worker.list=jk-statusworker.jk-status.type=statusworker.jk-status.read_only=trueworker.list=jk-managerworker.jk-manager.type=status - Restart Tomcat and Apache2.