Bookmark Topic Watch Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
This describes a way to proxy Tomcat requests through Apache Httd Web Server. I found mod_jk way overly complicated for development purposes. Whether or not proxies are a good idea in production, I do not know.

************************* Warning !!! **************************************************

I found this article while doing a search and noticed some very bad code, specifically this:

The above code will allow anyone to forward stuff like spam through your Apache server!!

I think that the original author really wanted to set up a reverse proxy, not a forward proxy.
Forward proxies are used for things like providing Intranet members with a connection to the Internet. Reverse proxies are used for clustering, load balancing, etc.

Unless you know what you are doing a good rule of thumb is to NEVER include this directive in your httpd.conf file:

In fact, unless you are truly creating a forward proxy, you should ALWAYS include this directive:

I have not changed anything in this article other than to add this warning.

H. Hall

I am assuming the following versions of Apache Httpd and tomcat

Apache Httpd 2.0.59

Tomcat 5.5.20

I am currently running Xubuntu Edgy and have installed Apache2 using apt-get.

First, you need to enable proxies in Apache. You can do the following commands from anywhere on the filesystem.

sudo ln -s /etc/apache2/mods-available/proxy.conf /etc/apache2/mods-enabled/proxy.conf

sudo ln -s /etc/apache2/mods-available/proxy_http.load /etc/apache2/mods-enabled/proxy_http.load

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

Next, edit /etc/apache2/mods-available/proxy.conf with your favorite editor (like VIM) and turn proxies on for All domains. (You can also restrict to specific domains, but since this is local machine development, this is just as easy)

Now that proxies are enabled, we need to define one. Create a file with the same name as your web application context in the following location:


For this example, our app is called testApp. Using your favorite editor (like VIM) use the following configuration:

DocumentRoot points to the location where you are serving static content from, like images, styles, scripts, etc. The ProxyPass and ProxyPassReverse tells apache httpd to send all dynamic requests to Tomcat.

Now, provide a sym link for this site in /etc/apache2/sites-enabled

sudo ln -s /etc/apache2/sites-available/testApp /etc/apache2/sites-enabled/testApp

The last thing is to edit your hosts file (/etc/hosts) to include the ServerName you have specified:

Now, just restart Apache (sudo apache2ctl restart) and you should be good to go. So now, rather than using port 8080, you would access your web app using the following:
    Bookmark Topic Watch Topic
  • New Topic