views:

224

answers:

2

Hi,

I've been trying to do this for some time unsuccesfully. I'll say in advance that this is probably a newbie question so apologies but I do need some assistance with this.

I am trying to redirect requests to cgi-bin/java-rmi.cgi to a servlet on tomcat (from apache). I've managed to redirect to the servlet successfully but I have not been able to do an implicit redirections (hiding the url change from the client).

This is mandetory since rmi will not work if it is redirected so I have to hide this from the client.

Right now my httpd.conf looks like this (only the relevant stuff obviously)

RewriteEngine on
RewriteLog logs/rewrite.log
RewriteLogLevel 9
RewriteRule ^/cgi-bin/java\-rmi\.cgi http://localhost/RMIServlet [P]

Alias /RMIServlet "C:/Program Files (x86)/Apache Software Foundation/Tomcat 6.0/webapps/RMIServlet"
<Directory "C:/Program Files (x86)/Apache Software Foundation/Tomcat 6.0/webapps/RMIServlet/">
Options Indexes FollowSymLinks
</Directory>

include "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/mod_jk.conf"

additionally, my mod_jk.conf looks like this (again, only relevant stuff)

# Send everything!! to worker ajp13
JkMount / ajp13
JkMount /* ajp13

(although I presume mod_jk.conf has nothing to do with the problem)

I also enabled these:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module mo

dules/mod_rewrite.so

Whenever I try to open http://localhost/cgi-bin/java-rmi.cgi the page opens with the url http://localhost/RMIServlet which is not good.

What am I doing wrong?

Thanks!

A: 

Try this instead? (Namely, omit the host portion?)

RewriteRule ^/cgi-bin/java\-rmi\.cgi /RMIServlet [P]
Amber
Thanks but It didn't work. :-( (nothing changed...)
Ben
Oh, I misunderstood the issue. Do you have any other RewriteRules defined?
Amber
I don't. all of the changes i've done (apart from the worker.properties file) are pasted here.
Ben
Hmm. The only thing I could think of is that Proxy mode might be forcing a redirect. By default, rewrites shouldn't normally be browser redirects unless the [R] option is specified, so the fact that it's doing a browser redirect is puzzling.
Amber
:( puzzled seems to describe my situation quite well.
Ben
Is it possible the servlet itself is issuing a redirect?
Amber
I tested this (after reading your suggestion) by turning tomcat off (and by so the servlet) and entering the cgi-bin url. It came back with a 503 (Service Termporary Unavailable) on http://localhost/RMIServlet/.Meaning - It was directed from apache.(Thanks Again)
Ben
I suppose another thing to check would be whether it's the proxy module forcing the redirect - try changing [P] to [L], and see if the url still gets browser-redirected (obviously, the servlet probably won't work properly w/o the proxy module; but at least it will determine whether the proxy is forcing a redirect).
Amber
I Did what you said and when I use "http://localhost/cgi-bin/java-rmi.cgi" I now get a 404. I'm not completely sure I understand what this means though.
Ben
Also, the url bar address doesn't change from what i typed
Ben
If the url bar address doesn't change, then Apache is correctly doing a non-browser rewrite when proxy mode is disabled. For some reason it looks like proxy mode is forcing the browser redirect for some reason.
Amber
A: 
  1. Dav is wrong, with [P] the replacement needs to be a qualified URI, including protocol and hostname.

  2. Is mod_proxy really active and configured correctly? Sorry, I can't help you with that, as I have not used done this yet.

  3. Try defining RMIServlet before rewriting the URL.

  4. Perhaps there is another rewriting going on after your rule, try appending L for last rule, so make it RewriteRule ^/cgi-bin/java\-rmi\.cgi http://localhost/RMIServlet [P,L]

Residuum