[users@httpd] help needed on Load balancing and environment variables scope

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hy everybody,
I'm configuring Apache as a reverse proxy and I am doing loadbalancing between some backend servers.
I' am doing load balancing using mod_rewrite. My backend webapps (every webapp is replicated in various servers) use cookies to mantain sessions.
 
So my goal was to redirect every user to same server he first was redirected to.
I achieved this setting the environment variable SERVER to the server name the user is first redirected to, then storing this value in a cookie; all the following request of the same user are then redirected to the server whose name is stored in the "backend_server" cookie.
 
 My question is:
what is the scope of the SERVER environment variable ? What happens if many users request simultaneusly ? Does the value of SERVER is shared inconsistently ?
I mean...may a user be redirected to the wrong server ?
 
Below I enclose the my config.
 
Any help is really appreciated.
Thanks
Andrea
 
 
RewriteMap lb rnd:/usr/local/apache2/conf/backend.table
RewriteCond %{HTTP_COOKIE} (^|(.+;)*)backend_server=(.+)(;?)
RewriteRule ^/s1_webconsole/(.*)$  http://%3/webconsole/$1 [E=SERVER:%3,P,L] 
RewriteCond %{HTTP_COOKIE} !(^|(.+;)*)backend_server=(.+)(;?)
RewriteRule ^/s1_webconsole/(.*)$  to://${lb:www}/$1
RewriteRule ^to://([^/]+)/(.*)$  http://$1/$2 [E=SERVER:$1,P,L] 
 
<Location /s1_webconsole>
...
Header add Set-Cookie backend_server=%{SERVER}e;Path=/s1_webconsole
 ...
</Location>

[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux