lunes, 4 de mayo de 2009

tomcat 5.5 behind apache 2.2

Recently I needed to add a web application hosted in tomcat 5.5 to an apache 2.2 web server that already serves static content, svn, web dav, etc. I tried lots of ways of making this, and in this document I will describe the best sollution I've found.

In your apache's httpd.conf file add the following lines, for example at the end of the file:


LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
<Location /tomcatSite/ >
ProxyPass ajp://localhost:8009/
</Location>


This tells apache that all http requests pointing to http://yourhost/tomcatSite/ will be redirected to a running apache instance. So save the file, restart apache, start tomcat and try to navigate to http http://yourhost/tomcatSite/. In a regular tomcat installation you should see the tomcat's main page.

The idea is that apache to listen on port 80 and tomcat to listen on another port, for example 8080. In my case as I said, this allow me to have my j2ee application in http://yourhost/tomcatSite/ but taking advantage of apache's flexibility, efficiency, supported protocols/servers like svn, webdav, etc.

I hope this can be usefull for somebody as it was for me...

No hay comentarios: