0

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

[update]

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

1 Answer 1

0

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:

NameVirtualHost 192.168.1.2:80

<VirtualHost 192.168.1.2:80>
       ServerName myjavaapp.com

       ProxyRequests Off
       ProxyPass         /      http://localhost:8080/
       ProxyPassReverse  /      http://localhost:8080/
</VirtualHost>

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/.

2
  • 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? Jun 8, 2011 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, 2011 at 22:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .