You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by da...@fedex.com on 2004/02/16 20:02:11 UTC

Tomcat 5 / mod_proxy

Hi - 

I am having a problem using mod_proxy w/ Apache 2.0.X and Tomcat 5.0.16.

I have been using mod_proxy for several years now to connect Apache (w/ 
SSL) to Tomcat. When 
recently upgrading to TC5, I noticed a problem.

My httpd config file looks something like this :
ServerName www.foobar.com
....
ProxyRequests ON
....
ProxyPass /foo http://ip.of.tomcat:port/foo
ProxyPassReverse /foo http://ip.of.tomcat:port/foo

ProxyPass /bar http://ip.of.tomcat:port/bar
ProxyPassReverse /bar http://ip.of.tomcat:port/bar

Tomcat 5 config:

<Connector port="8081"
               maxThreads.... etc etc
               proxyName="www.foobar.com" proxyPort="443">

<Context path="/foo">
....
</Context>

<Context path="/bar">
....
</Context>

(to get something like https://www.foobar.com/foo)

As soon as I use more than 1 set of ProxyPass/ProxyPassReverse statements, 

my sessions get all screwed up. 
After I add data to the session a first time, the next time I get the 
session it's completely empty. This all happens after
a form based login... If I use one set of ProxyPass/ProxyPassReverse 
statements, things seem to work ok.

This *only* happens if I use Tomcat 5. Our configs havn't changed 
otherwise...The app works fine if I go through a
regular, unproxied connector (without using Apache). All data being put 
into the session is serializable etc.

I've setup mod_jk to work around this, however mod_proxy is more desirable 

in our current configuration.

Anyone have any ideas?

Thanks,
Dave

Re: [OT] HTTP and tomcat filter question

Posted by Justin Ruthenbeck <ju...@nextengine.com>.
Duane,

This is a pretty crazy set of requirements you're working with here -- 
I'll trust there's a good reason for it and just stick to the question.  ;)

At 11:34 AM 2/16/2004, you wrote:
>Assuming I have a URL of
>http://www.mysite.com/myservlet.jsp?myvar=1&yourvar=2

Your URL is: "http://www.mysite.com/myservlet.jsp"
Your Query String is: "myvar=1&yourvar=2"

>When the browser sends this request to tomcat (which is also acting as a
>webserver - no apache is running), does it put everything after the ? into
>the QUERY_STRING HTTP variable, or does it include it in the URL request?

It parses the GET request into the two components listed above.

>I have a filter in place that will replace /variable/ with &variable= to
>allow for proper processing of variables.  Here is what I observe :
>
>If I have a URL of :
>mysite.com/myservlet.jsp/myvar/1/yourvar/2
>
>then it will properly translate this into :
>mysite.com/myservlet.jsp?myvar=1&yourvar=2
>
>and everything works.

Looks good.

>However, we have a new requirement that we want to keep ?myvar=1 as part
>of the original URL, so the incoming request would look like this :
>mysite.com/myservlet.jsp?myvar=1/yourvar/2

Your URL is: "http://www.mysite.com/myservlet.jsp"
Your Query String is: "myvar=1/yourvar/2"

AND

request.getParameter("myvar") == "1/yourvar/2"

>and, naturally, we want it translated into
>mysite.com/myservlet.jsp?myvar=1&yourvar=2
>
>but this does NOT happen.  Instead, it seems like the filter is doing
>nothing.
>The only explanation I can think of is that, now that the ? is in the
>original request URL, the browser is taking everthing after it, stripping
>it out of the request URL, and putting it into the QUERY_STRING variable -
>so that the filter doesn't see it.  The filter would only see
>mysite.com/myservlet.jsp
>and would not perform any translation.

This is exactly what's happening.  If you want to inspect the entire GET 
request, you need to reconstruct the entire GET request by doing 
something like this (pseudo code):

StringBuffer sb = request.getRequestURL();
sb.append("/");
parse request.getQueryString() into name=value pairs and name/value pairs
for each pair
     if pair is name=value, convert each name=value pair into a 
name/value pair
     sb.append(name/value pair)

Or whatever, depending on what you need.

Hope that clears up any confusion.  Again, I hope -- for your own sake -- 
you have a *really* good reason for complicating this relatively simple 
process.  ;)

justin


______________________________________________
Justin Ruthenbeck
Software Engineer, NextEngine Inc.
justinr - AT - nextengine DOT com
Confidential. See:
http://www.nextengine.com/confidentiality.php
______________________________________________


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


[OT] HTTP and tomcat filter question

Posted by Duane Burchell <bu...@engsoc.org>.
This question is a bit OT, since it deals more with HTTP than tomcat (I
think), but maybe somebody can help.

I'm (still) working with setting up filters in Tomcat, and am seeing some
erratic behavior, which leads me to ask this question :

Assuming I have a URL of
http://www.mysite.com/myservlet.jsp?myvar=1&yourvar=2

When the browser sends this request to tomcat (which is also acting as a
webserver - no apache is running), does it put everything after the ? into
the QUERY_STRING HTTP variable, or does it include it in the URL request?

I have a filter in place that will replace /variable/ with &variable= to
allow for proper processing of variables.  Here is what I observe :

If I have a URL of :
mysite.com/myservlet.jsp/myvar/1/yourvar/2

then it will properly translate this into :
mysite.com/myservlet.jsp?myvar=1&yourvar=2

and everything works.

However, we have a new requirement that we want to keep ?myvar=1 as part
of the original URL, so the incoming request would look like this :
mysite.com/myservlet.jsp?myvar=1/yourvar/2

and, naturally, we want it translated into
mysite.com/myservlet.jsp?myvar=1&yourvar=2

but this does NOT happen.  Instead, it seems like the filter is doing
nothing.
The only explanation I can think of is that, now that the ? is in the
original request URL, the browser is taking everthing after it, stripping
it out of the request URL, and putting it into the QUERY_STRING variable -
so that the filter doesn't see it.  The filter would only see
mysite.com/myservlet.jsp
and would not perform any translation.

Does this make any sense?  I've been reading up on HTTP all over the net,
but can't find any sites that really look at how the URL request is broken
down when variables are present.

Any help is greatly appreciated.

- Duane

ps.  For those of you who inquired about my success with the tomcat
filter, I will post an update once I get things working ... and hopefully
it will help some of you as well.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org