Search code examples
apachecoldfusiontomcat6mod-proxyrailo

ProxyPassReverse to Tomcat adding path to URL


I'm running Railo 3 in Tomcat 6.0.32. The tomcat server is fronted by Apache 2.2.20. Tomcat and Apache are pre built binaries from openCSW. Railo is just the latest build war deployed in tomcat's autodeploy dir webapps.

Everything is working fine when I try to access railo and content on the tomcat server.

It fails however, when railo on tomcat redirects me to itself. Mostly, when a cfm script uses the CGI.script_name, it will be returned wrong.

On the Apache side, the content is available on www.hostname.com. Apache redirects the user to tomcat through AJP on www.hostname.com:8009/railo/content.

A script on tomcat (taken from open OAuth example) is available at:

/opt/csw/share/tomcat6/webapps/railo/content/oauth_test/examples/admin_consumers.cfm

When I access it and try to perform some action, it calls itself with a few parameters, but at that point, railo dumps out an error, complaining that the file can not be found:

Page /content/railo/content/oauth_test/examples/admin_consumers.cfm [/opt/csw/share/tomcat6/webapps/railo/content/railo/content/oauth_test/examples/admin_consumers.cfm] not found

As you can see railo added twice the relative path from tomcat: /railo/content/railo/content

This is my configuration for the virtual host in Apache:

<VirtualHost *:443>
    ServerName www.hostname.com
    DocumentRoot "/opt/www/hostname/htdocs/"

    ProxyRequests Off
    <proxy *="">
        Order deny,allow
        Allow from all
    </proxy>

    ProxyPass / ajp://www.hostname.com:8009/railo/content/
    ProxyPassReverse / http://www.hostname.com:8888/railo/content/
</VirtualHost>

I tried several variant for the ProxyPassReverse directive, but with no luck so far. Based on extensive searches on the web (The Mystery of ProxyPassReverse), I tried this for the proxypassreverse:

    ProxyPassReverse / ajp://www.hostname.com:8009/railo/content/
    ProxyPassReverse / http://www.hostname.com:8888/railo/content/
    ProxyPassReverse / http://localhost:8888/railo/content/
    ProxyPassReverse / https://www.hostname.com

The tomcat server also has a virtual host defined like this:

 <Host name="www.hostname.com">
    <Context path="" docBase="/opt/csw/share/tomcat6/webapps/railo/content" />
 </Host>

But everytime, I always get the error from Railo.

Has anyone ever seen this problem with Railo, or CGI, and has an idea how to fix it?


Solution

  • You are specifying "/railo/content" twice. Once in your "docBase" attribute and again in your Proxy attributes. So, requests being proxied through Apache are going to have "railo/content/" twice in their request paths because you have it listed twice: once in Apache, another time in Tomcat.

    Try leaving off the /railo/content/ in your ProxyPassReverse attribute:

    ProxyPassReverse / http://www.hostname.com:8888/

    This will let the Tomcat config add the /railo/content/ bit all by itself.