What is the easiest way to install tomcat6 under apache2 in a Debian system?

The idea is to have all incoming connections on port 80 of a specific host to be redirected to a specific Application under tomcat webapps directory.

So for example: http://app1.myhost.com:80 goes to http://myhost.com:8080/app1/ http://app2.myhost.com:80 goes to http://myhost.com:8080/app2/

and so on


What if the machine I'm trying to configure does not have a valid IP? Actually, to access the machines port 80, I need to connect to port 54080 on another host, which redirects to the machine's port 80


This question is very vague, but I'll take a stab at it. (Edit: question was clarified a bit more)

It sounds like you want to know how to configure tomcat6 to run a Java application behind an Apache2 reverse proxy. This is a pretty standard configuration.

In Debian, I believe this will involve setting up the proper modules by ensuring that /etc/apache2/mods-available/mod_proxy.so is symlinked into the /etc/apache2/mods-enabled directory.

Then you have to configure a VirtualHost that will listen on the proper IP address and proxy the requests to Tomcat. If the IP address is going to be shared hosting, you will have to use Name-Based VirtualHost (NameVirtualHost directive).

The mod_proxy configuration is pretty straightforward, looking something like:


       ServerName myjavaapp.com

       ProxyRequests Off
       ProxyPass         /      http://localhost:8080/
       ProxyPassReverse  /      http://localhost:8080/

Obviously this is a very simple configuration and can be expanded on easily (logging, more hostnames, using ajp instead of http, etc.)

This file should be saved in /etc/apache2/sites-available/my-site-name.conf and symlinked to /etc/apache2/sites-enabled/.

  • Is there any difference in using mod_proxy and mod_jk? I found the package libapache2-mod-proxy-html - this is the right mod_proxy debian package? – Daniel Cukier Jun 8 '11 at 17:30
  • mod_jk was the original module for proxying to an AJP13 tomcat instance. Now it's more preferable to use mod_proxy and mod_proxy_ajp (I believe the first depends on the second). I don't have a debian system handy but that looks correct. Packages that place files in /etc/apache2/mods-available/ typically start with libapache2-mod-something. – Kyle Smith Jun 8 '11 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.