Single Tomcat 7 Webapp with Apache2 with Ajp Connector

As I had to some pages to get this information together, here’s to to set up a single tomcat webapp as the root of an apache server (on Debian, but should work similarly on other systems).
Assuming you’re configuring the server for the domain abc123.com

Setup your tomcat whereever you like. Per default, it already has the necessary AJP connector configured on port 8009.

In order for your webapp to be the root webapp, delete the existing ROOT directory, and rename your war file to ROOT.war and put it in the webapps directory, then start Tomcat. That’s it for Tomcat.

For the Apache configuration (being root), go to /etc/apache2/sites-available, create a file named abc123.com (yes, .com not .conf. But abc123.com.conf might work too) and put the following in it

<VirtualHost *:80>
    ServerName abc123.com
    ServerAlias *.abc123.com
    ProxyPreserveHost on
    ProxyRequests     off
    ProxyPass / ajp://localhost:8009/
    ProxyPassReverse / ajp://localhost:8009/
</VirtualHost>

and run

a2ensite abc123.com
a2enmod proxy_ajp
service apache2 restart

After this, you webapp should be available at abc123.com

This entry was posted in Software. Bookmark the permalink.