Tomcat and Apache HTTP Server

Posted under » Ubuntu » Linux » Apache on 20 July 2010

Most of the time, you already have a web server running at port 80 and its probably Apache. To begin you must install Tomcat first.

If you read my reverse proxy, I've used mod_rewrite for the wrapping which is quite easy to do but not efficient. Tomcat is just a bit harder.

#1 on Tomcat itself you have to enable the AJP Connector by modifying the server.xml at the conf. location.


<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Restart Tomcat.

#2 Enable the required Apache proxy module

If using Ubuntu.

ln -s /etc/apache2/mods-available/proxy_balancer.load /etc/apache2/mods-enabled/proxy_balancer.load
ln -s /etc/apache2/mods-available/proxy_ajp.load /etc/apache2/mods-enabled/proxy_ajp.load
ln -s /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabled/proxy.load

#3 Change the Apache config

<VirtualHost *:80>
    ServerName example.com.sg
    ProxyRequests Off
   <Proxy *>
     Order deny,allow
     Allow from all
   </Proxy>
ProxyPass / ajp://localhost:8009/docs/
ProxyPassReverse / http://example.com.sg/
</VirtualHost>

Thanks to humboldt for the ProxyPassReverse tip.

Restart Apache.

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS data