Integrate Apache2 with Tomcat on Ubuntu 9.10 server

There are several ways of integrating tomcat with apache. This tip provide instruction for interating tomcat with apache. For instruction to set up virtual host or multi virtual host in tomcat and also integrating with apache please see tomcat tips

Use AJP connector

  • Type following command: sudo a2enmod proxy. This will enables both proxy modules
  • To redirect all incoming requests to your tomcat you can simply update your default site under sites-available directory
  • First cd to /etc/apach2/sites-available. Then, sudo vi default.
    Next is to modify the Virtual Host block
    Next, add following lines into Virtual Host block sample file can be found here
    ProxyPass / ajp://localhost:8009/
    ProxyPassReverse / ajp://localhost:8009/
    This will redirect all incoming request to port 80 to tomcat that runs on port 8009 (AJP port). To add more virtual hosts one can simply clone this default and include a ServerName directive for new domain name.

Use ProxyPass and ProxyPassReverse on port 8080

  • Type following command: sudo a2enmod proxy. This will enables both proxy modules
  • To redirect all incoming requests to your tomcat you can simply update your default site under sites-available directory
  • First cd to /etc/apach2/sites-available. Then, sudo vi default.
    Next is to modify the Virtual Host block
    Next, add following lines into Virtual Host block sample file can be found here
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
    This will redirect all incoming request to port 80 to tomcat that runs on port 8080 (HTTP port). To add more virtual hosts one can simply clone this default and include a ServerName directive for new domain name.

Use mod jk

Based on our experience with different types of connector. mod jk is not recommended as proxy ajp is much simpler to setup and less error prone. One can use proxy ajp to set up multi virtual hosting easily or map sub domain to tomcat sub domains etc.





2244 Old Mill Carrollton, TX 75007 (425) 367-8702
Copyright @ 2008 Tomcat Hosting Services. All Rights Reserved.