ich nutze einen Apache mit Load Balancing (mod_proxy / mod_proxy_balancer) vor zwei Glassfish Servern und habe ein Problem mit Sticky Sessions wenn der mit ProxyPassMatch gematchte Pfad nicht mit dem Deploypfad übereinstimmt.
Ein Beispiel (Konfiguration siehe unten):
- Eine Applikation ist auf dem Glassfish unter "/testApp" (unter Glassfish, nicht Apache) deployed, dann erzeugt Glassfish einen jsessionid Cookie mit der Pfadangabe "/testApp".
- Unterhalb von "/testApp" gibt es ein Unterverzeichnis "subdir".
- Ich möchte mit "/test" (unter Apache) direkt auf "/testApp/subdir" (Glassfish) zugreifen sowie mit "/testApp" normal auf "/testApp".
- Mit der untenstehenden Konfiguration klappt das auch (mit ProxyPassMatch; "/testApp*" wird auf "/testApp*/ gemappt und "/test/*" auf "/testApp/subdir/*"
- Aber Stickysessions funktionieren mit letzterem nicht. Der jsessionid-Cookiepfad lautet ja auf "/testApp", daher scheint Apache den für die "/test*" Abfrage nicht zu nutzen.
- Also "<apacheip>/testApp/subdir/foo" hat Sticky Sessions und die auf das selbe zeigende "<apacheip>/test/foo" hat keine.
Wie sage ich dem Apache, daß er für Anfragen auf "/test*" den jsessionid-Cookie mit dem Pfad "/testApp" nutzen soll?
In der Doku zu "mod_proxy" gibt es folgenden Hinweis zur stickysession-Option: "The first part is for the cookie the second for the path." Aber das ist nicht hilfreich, denn nirgendwo finde ich einen Hinweis, wo und wie ich den Pfad der Option mitgebe.
Apachekonfiguration:
- Code: Select all
<Proxy balancer://default>
BalancerMember http://xxx.xxx.xxx.101:8080 route=0
BalancerMember http://xxx.xxx.xxx.102:8080 route=1
ProxySet lbmethod=byrequests
</Proxy>
ProxyPreserveHost On
<Location /test>
Order allow,deny
Allow from all
</Location>
<Location /testApp>
Order allow,deny
Allow from all
</Location>
ProxyPassMatch ^.*/test(.*)$ balancer://default/testApp/subdir/$1 stickysession=JSESSIONID|jsessionid nofailover=On
ProxyPassMatch ^(.*/testApp.*)$ balancer://default$1 stickysession=JSESSIONID|jsessionid nofailover=On
ProxyPassReverse / balancer://default