tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Van den Branden <ron.vandenbran...@kantl.be>
Subject Re: adding a global URI prefix for Tomcat web apps
Date Wed, 18 Apr 2012 13:19:24 GMT
Hi,

Thanks a million for guiding me through these hoops, and your patience 
with my confused anxiety to get this sorted out. It now works (of 
course) with these settings, and allows for a quite nice compromise. 
I'll briefly summarize problem and solution, if it can help others.

The starting point was that I needed to reverse proxy Tomcat webapps 
behind Apache, with the Tomcat running on a non-public port. 
Additionally, some Tomcat apps need access to the host name of the 
original request, in order to generate working links. In order to avoid 
the problem that the proxied Tomcat doesn't 'see' the 'proxy' prefix of 
the original request, I decided to mirror that prefix for my Tomcat apps 
as well, and settle for following Apache proxy configuration:

   ProxyPreserveHost    on
   ProxyPass/apps/     http://localhost:8082/apps/
   ProxyPassReverse/apps/     http://mydomain/apps/

(note: the proxy domain in the second argument of ProxyPassReverse makes 
sure that location headers for redirects by the Tomcat apps are 
rewritten correctly by mod_proxy).

Therefore, the Tomcat apps must be made accessible at e.g. 
http://localhost:8082/apps/my_app/, with the /app/ prefix before the 
actual name of the web app. This can be done easily by renaming the 
physical folder or WAR filename containing the web app, by adding the 
prefix, followed by a hash character (#) before the actual name of the 
application, e.g.: F:\tomcatApps\apps#my_app. This works well, except 
for Cocoon-based web apps, which choke on the hash in the filename. 
Hence, for those apps, following configuration provides a workaround:
     1. move the folder or WAR file containing the web app outside of 
the host's appBase path, e.g.: F:\cocoonApps\my_app
     2. add a file ${catalina.base}\conf\Catalina\[host 
name]\[prefix]#[app name].xml, e.g.: 
${catalina.base}\conf\Catalina\localhost\apps#my_app.xml, with following 
content:

     <Context docBase="F:/cocoonApps/my_app"/>

No further modifications of ${catalina.base}\conf\server.xml are needed.

Again, thanks for the great help!

Ron

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message