]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
backport of:
authorJean-Frederic Clere <jfclere@apache.org>
Fri, 20 Jul 2007 13:20:30 +0000 (13:20 +0000)
committerJean-Frederic Clere <jfclere@apache.org>
Fri, 20 Jul 2007 13:20:30 +0000 (13:20 +0000)
http://svn.apache.org/viewvc?view=rev&rev=550519
http://svn.apache.org/viewvc?view=rev&rev=551099
http://svn.apache.org/viewvc?view=rev&rev=551126
http://svn.apache.org/viewvc?view=rev&rev=551935
http://svn.apache.org/viewvc?view=rev&rev=554892
Allow to use different values for sessionid in url encoded id
and cookies. (PR 41897)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@557993 13f79535-47bb-0310-9956-ffa450edef68

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

diff --git a/CHANGES b/CHANGES
index fc4f0b36c5e0172ab22a04185c494f381e8bbee8..909944f9159857659ef4b1f4e9934eef8115074b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -24,6 +24,9 @@ Changes with Apache 2.2.5
   *) mod_cgi, mod_cgid: Fix use of CGI scripts as ErrorDocuments.
      PR 39710.  [Paul Querna, Ruediger Pluem]
 
+  *) mod_proxy: Allow to use different values for sessionid
+     in url encoded id and cookies. PR 41897. [Jean-Frederic Clere]
+
   *) mod_proxy: Fix the 503 returned when session route does
      not match any of the balancer members. [Mladen Turk]
 
diff --git a/STATUS b/STATUS
index ff757f6a820b419a0591a54ab5f4d52150785648..5ff21b2a3f02796ad3ffe7fa73d6b1f2d072503d 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -77,17 +77,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-    * mod_proxy: Allow to use different values for sessionid
-      in url encoded id and cookies. (PR 41897)
-      Trunk version of patch:
-        http://svn.apache.org/viewvc?view=rev&rev=550519
-        http://svn.apache.org/viewvc?view=rev&rev=551099
-        http://svn.apache.org/viewvc?view=rev&rev=551126
-        http://svn.apache.org/viewvc?view=rev&rev=551935
-        http://svn.apache.org/viewvc?view=rev&rev=554892
-      2.2.x version of patch:
-        http://issues.apache.org/bugzilla/attachment.cgi?id=20480
-      +1: jfclere, mturk, rpluem
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
 
index 2c16cbc8603cc49f0a107404b51ec546703b6287..0f96ee460dfdc23c07e4b32f9602e20e09ecdd73 100644 (file)
@@ -891,6 +891,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>
@@ -902,7 +905,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 cedd769434877e4cd3e2e7e83c9e9b5c84c19f8b..7d18990a882ae315669099aab2433b43048516ff 100644 (file)
@@ -684,6 +684,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>
@@ -695,7 +698,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 d02749b1ab32e2c0e867829fea1a4d65b814efad..e2f22235cf6f9384a6b4e12657bf898e499270ca 100644 (file)
@@ -234,16 +234,27 @@ static proxy_worker *find_route_worker(proxy_balancer *balancer,
 static proxy_worker *find_session_route(proxy_balancer *balancer,
                                         request_rec *r,
                                         char **route,
+                                        char **sticky_used,
                                         char **url)
 {
     proxy_worker *worker = NULL;
+    char *sticky, *sticky_path, *path;
 
     if (!balancer->sticky)
         return NULL;
+    sticky = sticky_path = apr_pstrdup(r->pool, balancer->sticky);
+    if ((path = strchr(sticky, '|'))) {
+        *path++ = '\0';
+         sticky_path = path;
+    }
+    
     /* Try to find the sticky route inside url */
-    *route = get_path_param(r->pool, *url, balancer->sticky);
-    if (!*route)
-        *route = get_cookie_param(r, balancer->sticky);
+    *sticky_used = sticky_path;
+    *route = get_path_param(r->pool, *url, sticky_path);
+    if (!*route) {
+        *route = get_cookie_param(r, sticky);
+        *sticky_used = sticky;
+    }
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                             "proxy: BALANCER: Found value %s for "
                             "stickysession %s", *route, balancer->sticky);
@@ -369,6 +380,7 @@ static int proxy_balancer_pre_request(proxy_worker **worker,
     int access_status;
     proxy_worker *runtime;
     char *route = NULL;
+    char *sticky = NULL;
     apr_status_t rv;
 
     *worker = NULL;
@@ -383,7 +395,7 @@ static int proxy_balancer_pre_request(proxy_worker **worker,
 
     /* Step 2: find the session route */
 
-    runtime = find_session_route(*balancer, r, &route, url);
+    runtime = find_session_route(*balancer, r, &route, &sticky, url);
     /* Lock the LoadBalancer
      * XXX: perhaps we need the process lock here
      */
@@ -493,12 +505,12 @@ static int proxy_balancer_pre_request(proxy_worker **worker,
     access_status = rewrite_url(r, *worker, url);
     /* Add the session route to request notes if present */
     if (route) {
-        apr_table_setn(r->notes, "session-sticky", (*balancer)->sticky);
+        apr_table_setn(r->notes, "session-sticky", sticky);
         apr_table_setn(r->notes, "session-route", route);
 
         /* Add session info to env. */
         apr_table_setn(r->subprocess_env,
-                       "BALANCER_SESSION_STICKY", (*balancer)->sticky);
+                       "BALANCER_SESSION_STICKY", sticky);
         apr_table_setn(r->subprocess_env,
                        "BALANCER_SESSION_ROUTE", route);
     }