You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jf...@apache.org on 2007/07/20 15:20:32 UTC

svn commit: r557993 - in /httpd/httpd/branches/2.2.x: CHANGES STATUS docs/manual/mod/mod_proxy.html.en docs/manual/mod/mod_proxy.xml modules/proxy/mod_proxy_balancer.c

Author: jfclere
Date: Fri Jul 20 06:20:30 2007
New Revision: 557993

URL: http://svn.apache.org/viewvc?view=rev&rev=557993
Log:
backport of:
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)


Modified:
    httpd/httpd/branches/2.2.x/CHANGES
    httpd/httpd/branches/2.2.x/STATUS
    httpd/httpd/branches/2.2.x/docs/manual/mod/mod_proxy.html.en
    httpd/httpd/branches/2.2.x/docs/manual/mod/mod_proxy.xml
    httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_balancer.c

Modified: httpd/httpd/branches/2.2.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/CHANGES?view=diff&rev=557993&r1=557992&r2=557993
==============================================================================
--- httpd/httpd/branches/2.2.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.2.x/CHANGES [utf-8] Fri Jul 20 06:20:30 2007
@@ -24,6 +24,9 @@
   *) 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]
 

Modified: httpd/httpd/branches/2.2.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/STATUS?view=diff&rev=557993&r1=557992&r2=557993
==============================================================================
--- httpd/httpd/branches/2.2.x/STATUS (original)
+++ httpd/httpd/branches/2.2.x/STATUS Fri Jul 20 06:20:30 2007
@@ -77,17 +77,6 @@
 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:
 

Modified: httpd/httpd/branches/2.2.x/docs/manual/mod/mod_proxy.html.en
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/docs/manual/mod/mod_proxy.html.en?view=diff&rev=557993&r1=557992&r2=557993
==============================================================================
--- httpd/httpd/branches/2.2.x/docs/manual/mod/mod_proxy.html.en (original)
+++ httpd/httpd/branches/2.2.x/docs/manual/mod/mod_proxy.html.en Fri Jul 20 06:20:30 2007
@@ -891,6 +891,9 @@
         <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 @@
     <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 />

Modified: httpd/httpd/branches/2.2.x/docs/manual/mod/mod_proxy.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/docs/manual/mod/mod_proxy.xml?view=diff&rev=557993&r1=557992&r2=557993
==============================================================================
--- httpd/httpd/branches/2.2.x/docs/manual/mod/mod_proxy.xml (original)
+++ httpd/httpd/branches/2.2.x/docs/manual/mod/mod_proxy.xml Fri Jul 20 06:20:30 2007
@@ -684,6 +684,9 @@
         <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 @@
     <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 />

Modified: httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_balancer.c?view=diff&rev=557993&r1=557992&r2=557993
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_balancer.c Fri Jul 20 06:20:30 2007
@@ -234,16 +234,27 @@
 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 @@
     int access_status;
     proxy_worker *runtime;
     char *route = NULL;
+    char *sticky = NULL;
     apr_status_t rv;
 
     *worker = NULL;
@@ -383,7 +395,7 @@
 
     /* 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 @@
     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);
     }