ʤä褦˵Ƴ

ǡäȤȡapache httpd-2.2.4źդmod_proxy_balancerεư

mod_proxy_balancerˤĤƤפmod_proxyϤγƼ⥸塼proxyХ󥷥󥰤Ǥ櫓Ǥʡmod_proxy_balancerΤϤʤΤ⥸塼ʤɡ󺤤äӤmod_proxy_ajpȤȤ߹碌Ĥޤmod_jk(2)ѤȤƻȤäȤΤȡ

Ȥwebؤapache(+mod_ajp +mod_proxy_balancer)1桢apؤtomcat2湽ˤȤstateful˿ʬ򤹤ɬפäơtomcatǥåץꥱ󤬻ȤʤstickysessionεǽȤ

httpd.confǤϤʤ󤸡

 ProxyPass /webapp/ balancer://testcluster/webapp/ stickysession=ss
 <Proxy balancer://testcluster>
        # r0
        BalancerMember ajp://192.168.100.10:8009 loadfactor=1 route=r0
        # r1
        BalancerMember ajp://192.168.100.11:8009 loadfactor=1 route=r1
 </Proxy>

ssȤѿr0Ȥʸ󤬴ޤޤ줿(ss=hogehhuga.r0 Τ褦˥ԥꥪ+ʸǽä)ˤajp://192.168.100.10:8009ˡajp://192.168.100.11:8009r1Ȥʸ󤬴ޤޤ줿ˤajp://192.168.100.11:8009proxyȤΡѿȤ϶ŪˤCookieCGIĶѿurlѤǤ륹Τ

tomcatղäƤjsessionidjvmRouteȤ߹碌stickysession¸Ǥ褦ˤʤ롣2tomcatjvmRouteˤ줾r0, r1ꤹȡUACookieȤˤʤäƤCookieJSESSIONID=hanamogerahogehoge.r0CookieȤʤUAˤURLѥ᡼Ȥ;jsessionid=gegehogegehoge.r0ȤäͤղäƤ롣httpd.confǰʲΤ褦ꤷƤСJSESSIONIDr0äƤtomcat(r0)ˡr1äƤtomcat(r1)ajp³Ƥ롣ĤsessionƱƥʤ³롢ȤȤߡ

 ProxyPass /webapp/ balancer://testcluster/webapp/ stickysession=JSESSIONID
 <Proxy balancer://testcluster>
        # r0
        BalancerMember ajp://192.168.100.10:8009 loadfactor=1 route=r0
        # r1
        BalancerMember ajp://192.168.100.11:8009 loadfactor=1 route=r1
 </Proxy>

stickysession=JSESSIONIDǤJSESSIONIDʸξˤmatchʤɤʤȤtomcatCookieǤJSESSIONIDʸurlǤjsessionidȾʸѿ̾ꤹ롣ȤCookieͭˤUAΤߤоݤˤȤǤʤCookieλȤʤѥȤʤɤ⺮ߺ礳ǤбǤʤ⺣λͤǤstickysessionʣꤹ뤳ȤǤʤ褦

ȤϤλͤapachebugzillaˤϿƤꡢԶȤǧϤƤ褦bugȤꤢpatchhttpd-2.2.4mod_proxy_balancer.c褦ˤΤ(ۤȤѤʤ)

 --- mod_proxy_balancer.c.orig   Wed May 23 11:09:16 2007
 +++ mod_proxy_balancer.c        Wed May 23 11:58:50 2007
 @@ -112,9 +112,18 @@
                              const char *name)
  {
      char *path = NULL;
 +    char *session_id = NULL;
 +    int  i;
 
 -    for (path = strstr(url, name); path; path = strstr(path + 1, name)) {
 -        path += strlen(name);
 +    session_id= apr_pstrdup(pool, name);
 +    /* Change 'JSESSIONID' to 'jsessionid' to match the value in the url */
 +    if (isupper(name[0])) {
 +      for (i=0;i<=strlen(session_id);i++)
 +       session_id[i] = tolower(session_id[i]);
 +    }
 +
 +    for (path = strstr(url, session_id); path; path = strstr(path + 1, session_id)) {
 +        path += strlen(session_id);
          if (*path == '=') {
              /*
               * Session path was found, get it's value

patchƤ뤳ȤǡȤꤢ̵ٵstickysessionʸǤmatch褦ˤƤ롣εư(ʸȾʸ̩˶̤)ԤˤpatchƤƤϤʤ

褳ȵưϤɤ٤ȤϡΤؤ󤫤ϤޤϢthreadùƤ褦ʤΤǡΥ꡼(httpd-2.2.5?)Ǥϲ餫μѹ