httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomcatastrophe <nab...@changethings.org>
Subject Re: AW: [users@httpd] Sticky sessions with Apache and Tomcat
Date Tue, 14 Jul 2009 23:47:17 GMT

Well, it's not a static page. I'll explain the situation better. I have a
message at the top of my page to show me which machine I've been handed to.
Machine 1 says "You are viewing this page from machine 1" and Machine 2 says
"You are are viewing this page from machine 2". So, when I get the page I
know which server it came from. I can also include a URL variable which will
set a session variable. setSession=true in the URL.

1.) I visit the site with setSession=true, it sets the session variable
called "visited" to true. On this page I see "You are viewing this page from
machine 1". I also see that the session variable exists and is true.

2.) I visit the site again and now (without setSession) I see "You are
visiting this page from machine 2" and it says that the session variable
doesn't exist.

3.) I visit again (also without setSession), I see "You are visiting this
page from machine 1" and it says the session variable does exist. So, my
session variable from the first visit still exists, it knows who I am. 

4.) Back to machine 2 again

It just goes back and forth like this. Machine 2 never realizes my session,
but Machine 1 does, so my session has been set. 

For whatever reason it keeps throwing me between machines.

So, I keep getting thrown back and forth between servers.



Juergen.Link-2 wrote:
> 
> Did you check the session cookie in your browser? 
> There should be one and it must end with either .jvm1 or .jvm2.
> If there is no session cookie, maybe your application didn't yet start a
> session - e.g. static html pages are served w/o a session.
> 
> Cheers
> J├╝rgen
> 
> 
>> -----Urspr├╝ngliche Nachricht-----
>> Von: tomcatastrophe [mailto:nabble@changethings.org] 
>> Gesendet: Montag, 13. Juli 2009 19:23
>> An: users@httpd.apache.org
>> Betreff: [users@httpd] Sticky sessions with Apache and Tomcat
>> 
>> 
>> I am trying to set up simple load balancing between Apache 
>> and two Tomcat instances, but am having problems with sticky sessions.
>> 
>> I get thrown back and forth between the instances on each 
>> request. (I put a note at the top of the page on each 
>> instance to distinguish where the page has been served from 
>> and each request sends me back to the other server. I see 
>> "instance 1" at the top of the page, then refresh and see 
>> instance 2, then refresh and see instance 1 again, etc)
>> 
>> My Apache Virtual Host:
>> 
>> <VirtualHost *:80>
>>      DocumentRoot "C:/Program Files (x86)/Apache Software 
>> Foundation/Tomcat 6.0/sites/foo/ROOT/"
>>      ServerName foo.com
>>      ServerAlias www.foo.com
>>      DirectoryIndex index.php
>> 
>>      <Directory "C:/Program Files (x86)/Apache Software 
>> Foundation/Tomcat 6.0/sites/foo/ROOT/">
>>      Allow from all
>>      </Directory>
>> 
>> 
>>      ProxyPreserveHost On
>>      ProxyPassReverse / ajp://192.168.1.2:8009/
>>      ProxyPassReverse / ajp://192.168.1.3:8009/
>> 	 
>>      ProxyPass / balancer://mycluster 
>> stickysession=JSESSIONID|jsessionid
>> nofailover=Off
>> 	 
>>      ProxyPass /balancer-manager !
>> 	 
>>      RewriteEngine On
>>      RewriteRule ^/(.*)$ balancer://mycluster/$1 [P,L,R]
>> 	 
>> <Proxy balancer://mycluster>
>> 	BalancerMember ajp://192.168.1.2:8009/ route=jvm1 loadfactor=50
>> 	BalancerMember ajp://192.168.1.3:8009/ route=jvm2 loadfactor=50
>> 	ProxySet lbmethod=byrequests
>> </Proxy>
>> 
>> <Location /balancer-manager>
>>         SetHandler balancer-manager
>>         Order Deny,Allow
>>         Deny from all
>>         Allow from 127.0.0.1
>> </Location>
>> 
>> </VirtualHost> 
>> 
>> 
>> My two Tomcat instances are set up as:
>> 
>>     <Engine name="Standalone" defaultHost="localhost" 
>> jvmRoute="jvm1">   
>> 
>>  and
>> 
>>     <Engine name="Standalone" defaultHost="localhost" 
>> jvmRoute="jvm2">   
>> 
>> 
>> Basically, what I want to happen is when I type in 
>> http://foo.com in the browser I am taken to jvm1 instance, 
>> when I type the same thing in another browser (new session) I 
>> am taken to jvm2 instance.
>> 
>> Then, everytime I visit any page on foo.com from either 
>> browser, I am always served from the original instance I was assigned.
>> 
>> Any help?
>> 
>> Thanks!!!
>> --
>> View this message in context: 
>> http://www.nabble.com/Sticky-sessions-with-Apache-and-Tomcat-t
>> p24465853p24465853.html
>> Sent from the Apache HTTP Server - Users mailing list archive 
>> at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> 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
>> 
>> 
> ---------------------------------------------------------------------
> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Sticky-sessions-with-Apache-and-Tomcat-tp24465853p24489722.html
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
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


Mime
View raw message