You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Pedro Salazar <pe...@ptinovacao.pt> on 2003/10/13 17:12:10 UTC

[users@httpd] mod_rewrite + ProxyPassReverse

Greetings,

I'm using apache mod_rewrite to redirect (proxy) requests to specific
context to a specific server port.

Below, I redirect everything that arrives to /tst/ngincard_06/ to the
same server on port 9080 without the prefix "/tst/".

RewriteRule ^/tst/ngincard_06/(.*)
http://%{SERVER_NAME}:9080/ngincard_06/$1 [L,P]

It works just fine, however, when the application code on the server
makes a redirect, the client will receive the url in 9080 port which is
unavailable to the client. So, I have to use the ProxyPassReverse but I
it's not working...

ProxyPassReverse :9080/ngincard_06/ :80/tst/ngincard_06/

My problem is how to say that only the redirect location on port 9080
should be replaced to /tst/ngincard_06/ on port 80.

Any hints?

thanks,
Pedro Salazar.
-- 
PS
pedro-b-salazar@ptinovacao.pt
PGP:0E129E31D803BC61


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_rewrite + ProxyPassReverse -> JSESSIONID LOST?? (UPDATED)

Posted by Pedro Salazar <pe...@ptinovacao.pt>.
On Tue, 2003-10-14 at 11:08, Pedro Salazar wrote:
> I believe that mod_proxy/mod_rewrite is loosing the jsessionid.
> 
> I have an application that stores a session variable X on a jsp, and
> then redirect to another jsp. In the other jsp, the session variable X
> does not exist. Probably that happens because jsessionid may be lost on
> mod_proxy/mod_rewrite... So any user session variable is lost!!
> 
> remember my rules:
> 
> ProxyPassReverse /tst/ngincard_06/
> http://192.168.89.158:9080/ngincard_06/
> RewriteRule ^/tst/ngincard_06/(.*)
> http://%{SERVER_NAME}:9080/ngincard_06/$1 [L,P]
> 

I have more information to update here.

a)- Using apache as proxy, the sessionid is not preserved;
b)- Using tomcat directly, the sessionid is preserved.

- In my JSP page, I redirect to a second JSP "redirect.jsp". If I print
what should be my redirected URL for redirect.jsp, in case a) it prints
only "redirect.jsp" but in case b) it prints
"redirect.jsp;jsessionid=8EE2AEB18452B6CF8BE0715E8A38ADEB".

Why it prints jsessionid as a parameter in case a) and in other one it
doesn't prints nothing?

Well, I figure that if in the working case b) does not prints anything,
the session id must be passed to client by another way... A find that a
header in the response as a cookie could be a way...

So, I added a header "set-cookie" with the value "JSESSIONID=XXXX" in
the application. And now it works fine!!!

Questions:
1- why sometimes it uses a query string parameter "jsessionid" on the
redirected URL and another times it uses a cookie header? What is the
right way?

2- If the jsessionid is passed by a query string parameter, shouldn't
the mod_proxy be able to work with that also?

thanks,
Pedro Salazar.
-- 
PS
pedro-b-salazar@ptinovacao.pt
PGP:0E129E31D803BC61


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_rewrite + ProxyPassReverse -> JSESSIONID LOST??

Posted by Pedro Salazar <pe...@ptinovacao.pt>.
I believe that mod_proxy/mod_rewrite is loosing the jsessionid.

I have an application that stores a session variable X on a jsp, and
then redirect to another jsp. In the other jsp, the session variable X
does not exist. Probably that happens because jsessionid may be lost on
mod_proxy/mod_rewrite... So any user session variable is lost!!

remember my rules:

ProxyPassReverse /tst/ngincard_06/
http://192.168.89.158:9080/ngincard_06/
RewriteRule ^/tst/ngincard_06/(.*)
http://%{SERVER_NAME}:9080/ngincard_06/$1 [L,P]

Is there any option to add on mod_proxy/mod_rewrite?

P.S.-Is any possibility to debug mod_proxy as we do in mod_rewrite?

thanks,
Pedro Salazar.
-- 
PS
pedro-b-salazar@ptinovacao.pt
PGP:0E129E31D803BC61


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_rewrite + ProxyPassReverse

Posted by Pedro Salazar <pe...@ptinovacao.pt>.
> The session/variables are being passed through a form (html input type).
> But, on server side (we are using jsp/servlets), when we try to get the
> parameters, they are null!! 
> 
> Maybe, I must put a filter to trap the http requests to see what is goig
> wrong...

It must have something about cookies... I believe that could be the
problem. 

Do you agree?

pedro salazar.
 


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_rewrite + ProxyPassReverse

Posted by Pedro Salazar <pe...@ptinovacao.pt>.
On Mon, 2003-10-13 at 17:49, Joshua Slive wrote:
> On Mon, 13 Oct 2003, Pedro Salazar wrote:
> > When I acess http://192.168.89.158:9080/ngincard_06/, the application
> > works just fine. But when I use http://192.168.89.158/tst/ngincard_06/,
> > the url I see in the browser still remains on port 80, but the user
> > session variables are not working!!!
> >
> > Is the ProxyPassReverse rule throwing away any session information?
> > The ProxyPassReverse shouldn't have a wildcard or it's implicit?
> 
> The wildcard is implicit.
> 
> As far as your problem, you need to be much more precise about exactly how
> the session variables are normally being transmitted.  ProxyPassReverse
> has no effect at all unless a redirect takes place, so that probably is
> not the problem.
> 
> Joshua.

The session/variables are being passed through a form (html input type).
But, on server side (we are using jsp/servlets), when we try to get the
parameters, they are null!! 

Maybe, I must put a filter to trap the http requests to see what is goig
wrong...

-- 
PS
pedro-b-salazar@ptinovacao.pt
PGP:0E129E31D803BC61


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_rewrite + ProxyPassReverse

Posted by Joshua Slive <jo...@slive.ca>.
On Mon, 13 Oct 2003, Pedro Salazar wrote:
> When I acess http://192.168.89.158:9080/ngincard_06/, the application
> works just fine. But when I use http://192.168.89.158/tst/ngincard_06/,
> the url I see in the browser still remains on port 80, but the user
> session variables are not working!!!
>
> Is the ProxyPassReverse rule throwing away any session information?
> The ProxyPassReverse shouldn't have a wildcard or it's implicit?

The wildcard is implicit.

As far as your problem, you need to be much more precise about exactly how
the session variables are normally being transmitted.  ProxyPassReverse
has no effect at all unless a redirect takes place, so that probably is
not the problem.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_rewrite + ProxyPassReverse

Posted by Pedro Salazar <pe...@ptinovacao.pt>.
> That doesn't seem like the correct syntax for ProxyPassReverse.  See:
> http://httpd.apache.org/docs-2.0/mod/mod_proxy.html#proxypassreverse
> 
> I'd guess something like this would be closer:
> ProxyPassReverse /tst/ngicard_06/ http://hostname.example.com:9080/ngincard_06/
> 
> Note that ProxyPassReverse can't do the %{SERVER_NAME} variable
> substitution, so you need to include the literal name there.
> 
> Joshua.

I'm having a problem with user session variables. The user/password I
submit in a form are not defined when using ProxyPassReverse. I mean, on
server side I that parameters are null. When accessing directly to
server on 9080 port works just fine.

My rules:

ProxyPassReverse /tst/ngincard_06/
http://192.168.89.158:9080/ngincard_06/
RewriteRule ^/tst/ngincard_06/(.*)
http://%{SERVER_NAME}:9080/ngincard_06/$1 [L,P]


When I acess http://192.168.89.158:9080/ngincard_06/, the application
works just fine. But when I use http://192.168.89.158/tst/ngincard_06/,
the url I see in the browser still remains on port 80, but the user
session variables are not working!!!

Is the ProxyPassReverse rule throwing away any session information?
The ProxyPassReverse shouldn't have a wildcard or it's implicit? 

thanks,
Pedro Salazar.
-- 
PS
pedro-b-salazar@ptinovacao.pt
PGP:0E129E31D803BC61


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_rewrite + ProxyPassReverse

Posted by Joshua Slive <jo...@slive.ca>.
On Mon, 13 Oct 2003, Pedro Salazar wrote:
> Below, I redirect everything that arrives to /tst/ngincard_06/ to the
> same server on port 9080 without the prefix "/tst/".
>
> RewriteRule ^/tst/ngincard_06/(.*)
> http://%{SERVER_NAME}:9080/ngincard_06/$1 [L,P]
>
> It works just fine, however, when the application code on the server
> makes a redirect, the client will receive the url in 9080 port which is
> unavailable to the client. So, I have to use the ProxyPassReverse but I
> it's not working...
>
> ProxyPassReverse :9080/ngincard_06/ :80/tst/ngincard_06/
>
> My problem is how to say that only the redirect location on port 9080
> should be replaced to /tst/ngincard_06/ on port 80.

That doesn't seem like the correct syntax for ProxyPassReverse.  See:
http://httpd.apache.org/docs-2.0/mod/mod_proxy.html#proxypassreverse

I'd guess something like this would be closer:
ProxyPassReverse /tst/ngicard_06/ http://hostname.example.com:9080/ngincard_06/

Note that ProxyPassReverse can't do the %{SERVER_NAME} variable
substitution, so you need to include the literal name there.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org