Tuesday, June 10, 2008

Integrate Apache Web Server 2.x with Tomcat 6.x on Windows XP

1) Enable Apache's HTTP proxy module by uncommenting the following lines in {APACHE_DIR}/conf/httpd.conf

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

2) Right at the end of the Load module section in httpd.conf, register URLs that should be forwarded to Tomcat like this:-
ProxyPass relative_url translated_url

For ex, Accessing a web application named 'tp' deployed on a local Tomcat server listening on port 8080 through Apache's http proxy (http://localhost/tp) would like this:-
ProxyPass /tp http://localhost:8080/tp

3) Add Apache's proxy to Tomcat's <connector> element associated with port 8080 in {TOMCAT_DIR}/conf/server.xml by adding the proxy attributes like this:-
<connector port="8080" protocol="HTTP/1.1"
connectiontimeout="20000"
redirectport="8443"
proxyName="localhost"

proxyPort="80"/>

That's all there is to it. You should now be able to access tomcat via Apache Web Server's HTTP reverse proxy.

No comments: