View | Details | Raw Unified | Return to bug 41897
Collapse All | Expand All

(-)docs/manual/mod/mod_proxy.xml (-1 / +4 lines)
Lines 684-689 Link Here
684
        <td>Balancer sticky session name. The value is usually set to something
684
        <td>Balancer sticky session name. The value is usually set to something
685
        like <code>JSESSIONID</code> or <code>PHPSESSIONID</code>,
685
        like <code>JSESSIONID</code> or <code>PHPSESSIONID</code>,
686
        and it depends on the backend application server that support sessions.
686
        and it depends on the backend application server that support sessions.
687
        If the backend application server uses different name for cookies
688
        and url encoded id (like servlet containers) use | to to separate them.
689
        The first part is for the cookie the second for the path.
687
    </td></tr>
690
    </td></tr>
688
    <tr><td>timeout</td>
691
    <tr><td>timeout</td>
689
        <td>0</td>
692
        <td>0</td>
Lines 695-701 Link Here
695
    <p>A sample balancer setup</p>
698
    <p>A sample balancer setup</p>
696
    <example>
699
    <example>
697
      ProxyPass /special-area http://special.example.com/ smax=5 max=10<br />
700
      ProxyPass /special-area http://special.example.com/ smax=5 max=10<br />
698
      ProxyPass / balancer://mycluster stickysession=jsessionid nofailover=On<br />
701
      ProxyPass / balancer://mycluster stickysession=JSESSIONID|jsessionid nofailover=On<br />
699
      &lt;Proxy balancer://mycluster&gt;<br />
702
      &lt;Proxy balancer://mycluster&gt;<br />
700
      <indent>
703
      <indent>
701
        BalancerMember http://1.2.3.4:8009<br />
704
        BalancerMember http://1.2.3.4:8009<br />
(-)modules/proxy/mod_proxy_balancer.c (-6 / +18 lines)
Lines 234-249 Link Here
234
static proxy_worker *find_session_route(proxy_balancer *balancer,
234
static proxy_worker *find_session_route(proxy_balancer *balancer,
235
                                        request_rec *r,
235
                                        request_rec *r,
236
                                        char **route,
236
                                        char **route,
237
                                        char **sticky_used,
237
                                        char **url)
238
                                        char **url)
238
{
239
{
239
    proxy_worker *worker = NULL;
240
    proxy_worker *worker = NULL;
241
    char *sticky, *sticky_path, *path;
240
242
241
    if (!balancer->sticky)
243
    if (!balancer->sticky)
242
        return NULL;
244
        return NULL;
245
    sticky = sticky_path = apr_pstrdup(r->pool, balancer->sticky);
246
    if ((path = strchr(sticky, '|'))) {
247
        *path++ = '\0';
248
         sticky_path = path;
249
    }
250
    
243
    /* Try to find the sticky route inside url */
251
    /* Try to find the sticky route inside url */
244
    *route = get_path_param(r->pool, *url, balancer->sticky);
252
    *sticky_used = sticky_path;
245
    if (!*route)
253
    *route = get_path_param(r->pool, *url, sticky_path);
246
        *route = get_cookie_param(r, balancer->sticky);
254
    if (!*route) {
255
        *route = get_cookie_param(r, sticky);
256
        *sticky_used = sticky;
257
    }
247
    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
258
    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
248
                            "proxy: BALANCER: Found value %s for "
259
                            "proxy: BALANCER: Found value %s for "
249
                            "stickysession %s", *route, balancer->sticky);
260
                            "stickysession %s", *route, balancer->sticky);
Lines 369-374 Link Here
369
    int access_status;
380
    int access_status;
370
    proxy_worker *runtime;
381
    proxy_worker *runtime;
371
    char *route = NULL;
382
    char *route = NULL;
383
    char *sticky = NULL;
372
    apr_status_t rv;
384
    apr_status_t rv;
373
385
374
    *worker = NULL;
386
    *worker = NULL;
Lines 383-389 Link Here
383
395
384
    /* Step 2: find the session route */
396
    /* Step 2: find the session route */
385
397
386
    runtime = find_session_route(*balancer, r, &route, url);
398
    runtime = find_session_route(*balancer, r, &route, &sticky, url);
387
    /* Lock the LoadBalancer
399
    /* Lock the LoadBalancer
388
     * XXX: perhaps we need the process lock here
400
     * XXX: perhaps we need the process lock here
389
     */
401
     */
Lines 476-487 Link Here
476
    access_status = rewrite_url(r, *worker, url);
488
    access_status = rewrite_url(r, *worker, url);
477
    /* Add the session route to request notes if present */
489
    /* Add the session route to request notes if present */
478
    if (route) {
490
    if (route) {
479
        apr_table_setn(r->notes, "session-sticky", (*balancer)->sticky);
491
        apr_table_setn(r->notes, "session-sticky", sticky);
480
        apr_table_setn(r->notes, "session-route", route);
492
        apr_table_setn(r->notes, "session-route", route);
481
493
482
        /* Add session info to env. */
494
        /* Add session info to env. */
483
        apr_table_setn(r->subprocess_env,
495
        apr_table_setn(r->subprocess_env,
484
                       "BALANCER_SESSION_STICKY", (*balancer)->sticky);
496
                       "BALANCER_SESSION_STICKY", sticky);
485
        apr_table_setn(r->subprocess_env,
497
        apr_table_setn(r->subprocess_env,
486
                       "BALANCER_SESSION_ROUTE", route);
498
                       "BALANCER_SESSION_ROUTE", route);
487
    }
499
    }

Return to bug 41897