mod_jk is an apache module which connects Tomcat to webservers. What this allows is for you to remove any port numbers from the url. In short mod_jk forwards requests from port 80 to port 8080 (or whatever port Tomcat is running on). Let’s get started.
sudo apt-get install libapache2-mod-jk
In the later versions on Tomcat (> v7) the redirect port is already enabled, so no need for this step, but here it is in any case:
sudo nano /opt/tomcat/conf/server.xml
Make sure that the following line is uncommented:
Create the workers.properties file:
sudo nano /etc/apache2/workers.properties
Paste the following inside the workers.properties:
worker.list=YOUR_WORKER_NAME worker.YOUR_WORKER_NAME.type=ajp13 worker.YOUR_WORKER_NAME.host=localhost worker.YOUR_WORKER_NAME.port=8009
This is not the default directory that mod_jk has for the workers.properties so we need to change this:
sudo nano /etc/apache2/mods-available/jk.conf
Then search for the following word: JkWorkersFile and change the path to:
/etc/apache2/workers.properties
Now configure that path Apache should pass through to Tomcat:
sudo nano /etc/apache2/sites-enabled/000-default
Insert the bold text within the VirtualHost tags:
<VirtualHost :80> ………………………………… ………………………………… JkMount / YOUR_WORKER_NAME </VirtualHost *:80>
The final step is to restart Apache:
sudo apache2 restart