redirect_* env vars passed by mod_jk not available in cgi scope

79 views
Skip to first unread message

Paul Klinkenberg

unread,
Oct 14, 2010, 4:44:09 PM10/14/10
to ra...@googlegroups.com
Hi all,

I want to try to keep this as simple as possible, I hope it will be :-)

I have an Apache webserver, which connects to tomcat+railo via mod_jk. This works.
I have a virtualhost setup as follows:
<VirtualHost *:80>
ServerName localhost
DocumentRoot /developing/somesite/
ErrorDocument 404 /404error.cfm
</VirtualHost>

Now, if I call a non-existing page http://localhost/page-does-not-exist, then Apache creates some extra "cgi variables", for example "cgi.redirect_url" and "cgi.redirect_query_string", and then calls the 404 handler /404error.cfm.
The code in 404error.cfm then checks those cgi variables to determine which url was requested, and then does other stuff, like showing a 404.

Now, in this mod_jk setup, these variables seemed to be gone. They are always an empty string (as with all undefined cgi vars).
 
So I tried using "JkEnvVar" in Apache's httpd.conf, to explicitly send those cgi vars, but that didn't help. I asked mister google for another 100 options, but didn't help.
Then I dug a little deeper, and checked the request itself:
<cfdump var="#getPageContext().getRequest().getAttribute('REDIRECT_URL')#" />
That gave a Null back.

But it had an interesting method getOriginalRequest(), so I tried:
<cfdump var="#getPageContext().getRequest().getOriginalRequest().getAttribute('REDIRECT_URL')#" />
And voila! There it was: "/page-does-not-exist".
This originalRequest is of type "org.apache.catalina.connector.RequestFacade" btw,a nd the getRequest is of type "railo.runtime.net.http.HTTPServletRequestWrap".

So now I know where I can digg those variables up, so my 404 page will work. But here's the question: shouldn't these variables already be available in the cgi scope? I think they should, because that's how it works when I used ACF / Resin+Railo behind an Apache webserver. Should it be seen as an error? I know that it will break some people's 404 code, especially if mod_jk will be used in the default railo installs.

Any insight on this is greatly appreciated.

Kind regards,

Paul Klinkenberg
www.railodeveloper.com




Paul Klinkenberg

unread,
Oct 15, 2010, 6:24:31 AM10/15/10
to ra...@googlegroups.com
Anyone? Should I file this as an enhancement request in JIRA?


Kind regards,

Paul Klinkenberg
www.railodeveloper.com




James Holmes

unread,
Oct 15, 2010, 6:31:13 AM10/15/10
to ra...@googlegroups.com
Please do, and I'll vote for it. I've been wanting this for a while.

Thanks for this BTW:

getPageContext().getRequest().getOriginalRequest().getAttribute('REDIRECT_URL')

I was digging around for a while looking for this but gave up out of
general laziness.
--
WSS4CF - WS-Security framework for CF
http://wss4cf.riaforge.org/

Paul Klinkenberg

unread,
Oct 15, 2010, 7:18:40 AM10/15/10
to ra...@googlegroups.com
The only reason why I continued was general stubbornness :-/ I kinda wished that I could have just let it go, it took me hours to find out.

Still, if anybody has any ideas about this, please reply!

Kind regards,

Paul Klinkenberg
www.railodeveloper.com



Gert Franz

unread,
Oct 15, 2010, 8:50:36 AM10/15/10
to ra...@googlegroups.com

Paul,

 

maybe we can add that as a default behavior if the REDIRECT_URL is null. I will check with dev…

 

Greetings from Switzerland

Gert Franz

 

Railo Technologies      Professional Open Source

skype: gert.franz         ge...@getrailo.com

+41 76 5680 231           www.getrailo.com

 

image001.jpg

Paul Klinkenberg

unread,
Oct 15, 2010, 9:21:20 AM10/15/10
to ra...@googlegroups.com
Hi Gert,

There are actually 8 of those redirect_* headers, so if it could be made with that pattern, great.
I assume there is an underying reason why these variables are not directly accessible from Railo's cgi scope; maybe a look into that could be a better solution.

Kind regards,

Paul Klinkenberg
www.railodeveloper.com




Op 15 okt 2010, om 14:50 heeft Gert Franz het volgende geschreven:

Paul,
 
maybe we can add that as a default behavior if the REDIRECT_URL is null. I will check with dev…
 
Greetings from Switzerland
Gert Franz
 
Railo Technologies      Professional Open Source
skype: gert.franz         ge...@getrailo.com
+41 76 5680 231           www.getrailo.com
 
<image001.jpg>

Darren Walker

unread,
Oct 15, 2010, 9:50:57 AM10/15/10
to ra...@googlegroups.com
Hi Paul, this sounds similar to a problem I had, which I resolved using:

GetPageContext().getRequest().getAttribute('javax.servlet.error.request_uri')

But this was with apache->tomcat via ajp.

Lovin' your work

Darren

Paul Klinkenberg

unread,
Oct 15, 2010, 10:13:04 AM10/15/10
to ra...@googlegroups.com
Hi Darren,

Thanks for the compliment :-)
Mod_jk actually also uses ajp13, so it is all alike, I guess.

If it would be usefull for you to have this attribute in the cgi scope as well (where it indeed should be, right?), then maybe you could add a comment to the jira issue about this? The issue url is: https://jira.jboss.org/browse/RAILO-1006

Kind regards,

Paul Klinkenberg
www.railodeveloper.com




Reply all
Reply to author
Forward
0 new messages