]> granicus.if.org Git - apache/commitdiff
Add sticky_path to solve PR41897.
authorJean-Frederic Clere <jfclere@apache.org>
Mon, 25 Jun 2007 14:42:25 +0000 (14:42 +0000)
committerJean-Frederic Clere <jfclere@apache.org>
Mon, 25 Jun 2007 14:42:25 +0000 (14:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@550519 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/mod/mod_proxy.html.en
docs/manual/mod/mod_proxy.xml
modules/proxy/mod_proxy.c
modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_balancer.c

index bc31ca60af1f00828d135ef01562f3cbd5af1508..1cec55bc792081702ac32fb3c9f7508d903ec8dd 100644 (file)
@@ -899,6 +899,9 @@ through</td></tr>
         <td>Balancer sticky session name. The value is usually set to something
         like <code>JSESSIONID</code> or <code>PHPSESSIONID</code>,
         and it depends on the backend application server that support sessions.
+        If the backend application server uses different name for cookies
+        and url encoded id (like servlet containers) use | to to separate them.
+        The first part is for the cookie the second for the path.
     </td></tr>
     <tr><td>timeout</td>
         <td>0</td>
@@ -910,7 +913,7 @@ through</td></tr>
     <p>A sample balancer setup</p>
     <div class="example"><p><code>
       ProxyPass /special-area http://special.example.com/ smax=5 max=10<br />
-      ProxyPass / balancer://mycluster/ stickysession=jsessionid nofailover=On<br />
+      ProxyPass / balancer://mycluster/ stickysession=JSESSIONID|jsessionid nofailover=On<br />
       &lt;Proxy balancer://mycluster&gt;<br />
       <span class="indent">
         BalancerMember http://1.2.3.4:8009<br />
index 55e2b7f79b65c7d9b838cd72df19f4403c97a0a6..3a0cce2a8dd0438012566d61fe9be6c7af8f9e5c 100644 (file)
@@ -709,6 +709,9 @@ expressions</description>
         <td>Balancer sticky session name. The value is usually set to something
         like <code>JSESSIONID</code> or <code>PHPSESSIONID</code>,
         and it depends on the backend application server that support sessions.
+        If the backend application server uses different name for cookies
+        and url encoded id (like servlet containers) use | to to separate them.
+        The first part is for the cookie the second for the path.
     </td></tr>
     <tr><td>timeout</td>
         <td>0</td>
@@ -720,7 +723,7 @@ expressions</description>
     <p>A sample balancer setup</p>
     <example>
       ProxyPass /special-area http://special.example.com/ smax=5 max=10<br />
-      ProxyPass / balancer://mycluster/ stickysession=jsessionid nofailover=On<br />
+      ProxyPass / balancer://mycluster/ stickysession=JSESSIONID|jsessionid nofailover=On<br />
       &lt;Proxy balancer://mycluster&gt;<br />
       <indent>
         BalancerMember http://1.2.3.4:8009<br />
index cf25829a5eb853a676b8dbeb725922adb62339c7..07110200a752cb5f5d97aa68ccf5e47a4a9f77aa 100644 (file)
@@ -275,11 +275,16 @@ static const char *set_balancer_param(proxy_server_conf *conf,
 
     int ival;
     if (!strcasecmp(key, "stickysession")) {
+        char *path;
         /* Balancer sticky session name.
          * Set to something like JSESSIONID or
          * PHPSESSIONID, etc..,
          */
-        balancer->sticky = apr_pstrdup(p, val);
+        balancer->sticky = balancer->sticky_path = apr_pstrdup(p, val);
+        if ((path = strchr(balancer->sticky, '|'))) {
+            *path++ = '\0';
+            balancer->sticky_path = path;
+        }
     }
     else if (!strcasecmp(key, "nofailover")) {
         /* If set to 'on' the session will break
index a8e8a260aef41879241f69a04e5b644fff3e654f..a6a8ecc30b3029b8581caa9be274b7b046eeb9e6 100644 (file)
@@ -365,6 +365,7 @@ struct proxy_balancer {
     apr_thread_mutex_t  *mutex;  /* Thread lock for updating lb params */
 #endif
     void            *context;   /* general purpose storage */
+    const char      *sticky_path;  /* URL sticky session identifier */
 };
 
 struct proxy_balancer_method {
index c82e24aecbd7594dc82358ec1d75d744318442f1..c3f9605c6a0d48fc1cfe29ce5c69e56ea2c1bc35 100644 (file)
@@ -248,12 +248,19 @@ static proxy_worker *find_session_route(proxy_balancer *balancer,
     if (!balancer->sticky)
         return NULL;
     /* Try to find the sticky route inside url */
-    *route = get_path_param(r->pool, *url, balancer->sticky);
-    if (!*route)
+    *route = get_path_param(r->pool, *url, balancer->sticky_path);
+    if (*route) {
+        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                     "proxy: BALANCER: Found value %s for "
+                     "stickysession %s", *route, balancer->sticky_path);
+    }
+    else {
         *route = get_cookie_param(r, balancer->sticky);
-    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
-                            "proxy: BALANCER: Found value %s for "
-                            "stickysession %s", *route, balancer->sticky);
+        if (*route)
+            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                         "proxy: BALANCER: Found value %s for "
+                         "stickysession %s", *route, balancer->sticky);
+    }
     /*
      * If we found a value for sticksession, find the first '.' within.
      * Everything after '.' (if present) is our route.