How do I connect Apache to Tomcat using a proxy?
Author: Deron Eriksson
Description: This tutorial describes how to connect the Apache Web Server to Tomcat using a proxy.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 1.5.4 || Tomcat 5.5.20 || Apache HTTP Server 2.2.4

Page: < 1 2

(Continued from page 1)

Now, it's time to set up ApacheSW. In my Apache httpd.conf configuration file, I uncomment:

LoadModule proxy_module modules/
LoadModule proxy_http_module modules/

In my httpd.conf file, I add ProxyPass and ProxyPassReverse entries. In the example below, requests to Apache's /tomcat-demo-proxy path get mapped to Tomcat's port 8082 connector running on the same machine, with the tomcat-demo project specified as the project that we get mapped to.

ProxyPass        /tomcat-demo-proxy http://localhost:8082/tomcat-demo
ProxyPassReverse /tomcat-demo-proxy http://localhost:8082/tomcat-demo

If you'd like to, you can check and make sure the syntax of httpd.conf is correct using the -t switch on httpd.exe:

C:\Apache2.2.4\bin>httpd.exe -t
Syntax OK


Next, I'll stop and start Apache. After that, I'll hit http://localhost/tomcat-demo-proxy/test in a browser window.

hitting test servlet via Apache

As you can see, the request to Apache's /tomcat-demo-proxy/test path gets mapped to http://localhost:8082/tomcat-demo/test, which is exactly the behavior we were hoping for. The request to Apache gets sent to TomcatSW. Tomcat processes the request and returns the response, which we see in the browser window.

Page: < 1 2