How to setup Tomcat and Apache via mod_proxy_ajp

This instruction is for an ubuntu server 10.10.

Tomcat6 configuration

Enable the AJP connector in the /etc/tomcat6/server.xml file like this:

Connector port="8009" enableLookups="false"
         redirectPort="8443" protocol="AJP/1.3"

Restart the Tomcat server.

$ sudo /etc/init.d/tomcat6 restart

Apache2 configuration

Enable the proxy and proxy_ajp modules

sudo a2enmod proxy proxy_ajp

Add new virtual host to the sites-available folder

$ sudo nano /etc/apache2/sites-available/

   ServerName localhost
   ErrorLog /var/log/apache2/ajp.error.log
   CustomLog /var/log/apache2/ajp.log combined

     AddDefaultCharset Off
     Order deny,allow
     Allow from all

   ProxyPass / ajp://localhost:8009/
   ProxyPassReverse / ajp://localhost:8009

Enable virtual host site and restart Apache2

$ sudo a2ensite
$ sudo /etc/init.d/apache2 restart

If you fail to set the ServerName then on an Apache restart you will see the following warning:

apache2: Could not reliably determine the server's
fully qualified domain name, using for ServerName

To stop the warning and set the ServerName, add the following to the apache2.conf:

ServerName demo
This entry was posted in Apache / Tomcat. Bookmark the permalink.

Leave a Reply