Setting up Tomcat behind Apache 2.2 in a hierarchical path
The situation I want to deal with is this:
Public Web Root
|-plone
\-portals
|-portal1 (server A)
\-portal2 (server B)
In apache 2.2 they (the writers of the Apache docs) seem to prefer the use of mod_proxy_ajp, which is an AJP/1.3 driver for mod_proxy. At the apache end we just install mod_proxy_ajp and add a line such as the following to the proxy_ajp.conf file:
ProxyPass /portals/portal1 ajp://nigel-dev:8009/portals/portal1
Note that the paths on the proxy host and the application server are the same. This is important, as at the application end it will only know its path name from its context, and unless you want to do some url rewriting, and possible use something called ProxyHTMLURLMap. It, like most potentially useful software, isn’t available in Red Hat, so we can’t investigate this option.
So, the purpose of this post is to explain how to get the application server’s paths to match the proxies. Do the following:
- Create the path structure with in the $CATALINA_HOME/webapps directory, ie $CATALINA_HOME/webapps/portals
- Install the WAR or webapp install into its place in the hierarchy
- Create a context xml file for each application. These go in $CATALINA_HOME/conf/Catalina/localhost, and are named the same as the webapps path, with # in place of /. ie $CATALINA_HOME/conf/Catalina/localhost/portals#portal1.xml and $CATALINA_HOME/conf/Catalina/localhost/portals#portal2.xml.
- Inside these files put the following:
<Context docBase="portals/portal1.war" cookies="true"> </Context>
The cookies is important to force the use of cookies as opposed to URL rewriting to preserve the sessions. The docBase is obviously the path to the webapp or WAR file.
-
Archives
- July 2009 (1)
- February 2009 (1)
- December 2008 (1)
- November 2008 (1)
- October 2008 (2)
- September 2008 (1)
- August 2008 (1)
- April 2008 (2)
- February 2008 (4)
- January 2008 (2)
- November 2007 (1)
- October 2007 (1)
-
Categories
-
RSS
Entries RSS
Comments RSS