0 Replies Latest reply on May 20, 2011 12:07 PM by slr242

    obtaining originally requested URI for 404 processing, Apache > JBoss > CF8


      Hey all.


      The issue I'm facing, in a (rather large) nutshell: when a user requests a directory which doesn't exist, Apache 2.2 forwards the request to JBoss 4.2.3.GA, which loads the 404 template that I've specified in the web.xml file. That happens to be our 404.cfm page which we run under CF8. That's all good. But, we lose all of the info regarding the original request. The script_name and path_translated vars both think that the request was to 404.cfm. Up until now, our application has sent requests for non-existent directories through IIS to JRun and CF, and the original request has been available to us. We've implemented shortcuts in our app which make use of this info, and it's critical that we have it when we rollout our new server. Help, please. :-)


      After much research, I've tried two things in Apache: the combo of ErrorDocument and mod_jk, and mod_rewrite.

      Below is a synopsis of each approach. If you have another solution, I'd love to hear it. :-)


      For the mod_jk approach,I'm doing a LoadModule for mod_jk, and I've added the following in the VirtualHost section of the httpd.conf file:

      ErrorDocument 404 /404.cfm

      JkMount /(applicationRoot)/* node1


      In the mod-jk.conf file, I'm creating environment vars which should get passed on to JBoss.

      JkEnvVar REDIRECT_URL undefined


      In my 404.cfm template, I'm calling a jsp page with the following code:



              out.println( request.getAttribute("REDIRECT_URL"));



      What I get in reponse after requesting a non-existent directory is...nothing. The variable doesn't seem to exist.


      This approach apparently works in Railo, where you can use getOriginalRequest() to get at the info you need.




      Anyway, going another route, if I instead use mod_rewrite within VirtualHosts and do something like this:




      RewriteRule ^(.+)$ /404.cfm?qs=%{REQUEST_URI}?%{QUERY_STRING} [L]




      I get sent to the 404, but the code is not proxied to JBoss and instead gets printed to the screen (yikes).




      If I do this:




      RewriteRule ^(.+)$ http://myserver.domain.com/404.cfm?qs=%{REQUEST_URI}?%{QUERY_STRING} [L]




      I get a redirect loop.




      If I do this:




      RewriteRule ^(.+)$ http://myserver.domain.com:8080/404.cfm?qs=%{REQUEST_URI}?%{QUERY_STRING} [L]




      I get sent to the 404 and voilà, I have the variables that I need, but I’m stuck in port 8080 where I don’t want to be.




      Finally, if I do this:




      RewriteRule /(\d+)\Z /404\.cfm\?qs=$1 [L]




      I get rerouted properly, but  I lose the original request.


      So, at the moment, I'm stuck. Have any of you run across a similar situation? Have a solution? Would love to hear it.


      Thanks for reading this far!