餱ȥƥȤͫݵ

⤷ƤȤɽεϿøȽ񤯡

Apache httpd

mod_proxy_balancerstickysessionʸʸ̤

ʤä褦˵Ƴ

ǡäȤȡ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?)Ǥϲ餫μѹ

http顼IPɥ쥹󥸤Ĵ

2009/09ɵ: ƤŤǤ

2ǯʬΥפȤäƤߤ

GoogleBot̾뤱ɤ¤ϰ㤦ΡפιθϤñgrepsort,uniqƤߤ

줾Υɥ쥹ޤޤwhoisΥȥϤ(IPɥ쥹󥸰ʳȴ)

 Google Inc. EC12-1-GOOGLE (NET-64-68-80-0-1)
                                  64.68.80.0 - 64.68.87.255

 OrgName:    Google Inc.
 NetRange:   66.249.64.0 - 66.249.95.255
 CIDR:       66.249.64.0/19
 NetName:    GOOGLE
 NetHandle:  NET-66-249-64-0-1
 RegDate:    2004-03-05
 Updated:    2004-11-10

 inetnum:      202.160.176.0 - 202.160.191.255
 netname:      YAHOO-ALIBABA-1
 descr:        Yahoo Inc, Internet Content Provider
 route:        202.160.176.0/20

INKTOMIYahoo!줿󥸥󶡴
 OrgName:    Inktomi Corporation
 NetRange:   66.196.64.0 - 66.196.127.255
 CIDR:       66.196.64.0/18
 NetName:    INKTOMI-BLK-3
 NetHandle:  NET-66-196-64-0-1
 RegDate:    2001-10-30
 Updated:    2005-08-26

 OrgName:    Inktomi Corporation
 NetRange:   68.142.192.0 - 68.142.255.255
 CIDR:       68.142.192.0/18
 NetName:    INKTOMI-BLK-4
 NetHandle:  NET-68-142-192-0-1
 RegDate:    2004-03-24
 Updated:    2005-08-26

 OrgName:    Inktomi Corporation
 NetRange:   72.30.0.0 - 72.30.255.255
 CIDR:       72.30.0.0/16
 NetName:    INKTOMI-BLK-5
 NetHandle:  NET-72-30-0-0-1
 RegDate:    2005-01-28
 Updated:    2005-10-19

 OrgName:    Microsoft Corp
 NetRange:   207.46.0.0 - 207.46.255.255
 CIDR:       207.46.0.0/16
 NetName:    MICROSOFT-GLOBAL-NET
 NetHandle:  NET-207-46-0-0-1
 RegDate:    1997-03-31
 Updated:    2004-12-09

 OrgName:    MS Hotmail
 NetRange:   64.4.0.0 - 64.4.63.255
 CIDR:       64.4.0.0/18
 NetName:    HOTMAIL
 NetHandle:  NET-64-4-0-0-1
 RegDate:    1999-11-24
 Updated:    2006-01-23

 OrgName:    MS Hotmail
 NetRange:   64.4.0.0 - 64.4.63.255
 CIDR:       64.4.0.0/18
 NetName:    HOTMAIL
 NetHandle:  NET-64-4-0-0-1
 RegDate:    1999-11-24
 Updated:    2006-01-23

Υ󥸤˴ޤޤ륢ɥ쥹ƥ顼ȤݾڤϤʤޤʳˤ⥯顼˳Ƥ줿IPɥ쥹ǽ(ǽ⤢)

VirtualHost˴ؤäȤФ

VirtualHostname-basedIP-based򺮺ߤ

IPv4ɥ쥹󤷤ɡIPv6ɥ쥹Ͻ˻ȤʤɤΤäȤ⡣httpd.confϤʴˤʤ롣

 Listen 123.45.67.89:80
 Listen [2001:3e0:4eb:9999:8000]:80
 Listen [2001:3e0:4eb:9999:8001]:80
 
 NameVirtualHost 123.45.67.89:80
 
 <VirtualHost 123.45.67.89:80 [2001:3e0:4eb:9999:8000]:80>
    DocumentRoot "/home/web/example.jp/htdocs"
    ServerName www.example.jp
 </VirtualHost>
 
 <VirtualHost 123.45.67.89:80 [2001:3e0:4eb:9999:8001]:80>
    DocumentRoot "/home/web/example.com/htdocs"
    ServerName www.example.com
 </VirtualHost>

DNSϤʤ󤸤ǡ

 www.example.jp.	IN	A	123.45.67.89
 www.example.jp.	IN	AAAA	2001:3e0:4eb:9999:8000
 www.example.com.	IN	A	123.45.67.89
 www.example.com.	IN	AAAA	2001:3e0:4eb:9999:8001

IPv4ɥ쥹(Ĥ꿶ʤɥ쥹)NameVirtualHostꤹΤݥȡȤϰŻˤIPɥ쥹VirtualHostؼҤ˥ڡǶڤäƵҡ̤IPv6ʤƤ⡢IPv4Х륢ɥ쥹ϰĤʤɡץ饤١ȥɥ쥹Ϥ󤢤롢ʤƾǤ⤪ޤ

ۥȥȥ˥磻ɥɤ

Ȥexample.jpɥᥤƱVirtualHostб硣www.example.jpǤweb.example.jpǤexample.jpǤwwwwwwwwwwwwwwwwwwwwwww.example.jpǤ⡦

DNSϤ

 example.jp.	IN	A	123.45.67.89
 *.example.jp.	IN	A	123.45.67.89

httpd.confϡ

 Listen 123.45.67.89:80
 <VirtualHost 123.45.67.89:80>
    DocumentRoot "/home/web/example.jp/htdocs"
    ServerName example.jp
    ServerAlias *.example.jp
 </VirtualHost>

ServerNameϤServerAliasname-basedλHost:ꥯȥإåȥޥåơɤVirtualHostܤ뤫Ǥ롣ʸ̤ꥨꥢǥ磻ɥɤꤷƤꡢexample.jpɥᥤΤɤ̾ƤƱVirtualHostޥå롣IPv6ξŬ󥸤ޤ礦

Ф񤭤ȸäƤ2ĤפĤʤäɡޤʤ󤫳ФפФꤷ񤭤ޤ

SIGUSR1򿩤ähttpd夬äƤʤ

ˤФеꡣä


Jun 1 00:00:00 ns newsyslog[92788]: logfile turned over

[Thu Jun 01 00:00:03 2006] [notice] seg fault or similar nasty error detected in the parent process




newsyslogǥơ󤹤SIGUSR1(ʥ30)äơե뵭һҤƤɬפɡǾ夬äƤʤ



äƤߤɤPHP4äݤʷϵФƤ
http://www.freebsd.org/cgi/query-pr.cgi?pr=64904
http://bugs.php.net/bug.php?id=27899
http://bugs.php.net/bug.php?id=27810

Ȥ褦ȻפΩäɡäѤ⤦̲鿲롣(Ȥäޤ֤)