Connect Apache to Tomcat Using mod_jk

Categories:

This short tutorial will explain how to connect Apache 2 to Tomcat 10 using mod_jk.

First thing, let’s install mod_jk.

sudo apt install libapache2-mod-jk

Now let’s create the workers properties file:

sudo vi /etc/apache2/workers.properties

Here is a simple workers.properties example:

#Define 1 real worker using ajp13
worker.list=ajp13
# Set properties for worker (ajp13)
worker.ajp13.type=ajp13
worker.ajp13.host=127.0.0.1
worker.ajp13.port=8009

Next, edit Tomcat’s server.xml file to enable the AJP connector (instead of uncommenting the existing line, for testing you can use this line):

<Connector protocol="AJP/1.3" address="127.0.0.1" secretRequired="false" port="8009" redirectPort="8443" />

Update your Virtual Host(s) to use the worker to process the files (you may filter which files go through Tomcat):

<VirtualHost *:80>
    ServerName mysite.com
...
...
JkMount /*.jsp ajp13
...
...
</VirtualHost>

Restart Tomcat and Apache

sudo systemctl restart tomcat
sudo systemctl restart apache2

Leave a Reply

Your email address will not be published. Required fields are marked *