Forum Discussion

kridsana_52318's avatar
kridsana_52318
Icon for Nimbostratus rankNimbostratus
Apr 24, 2015

Cookie persist Fail with One Virtual server but have many pool (different member too)

Hi

I have issue with persistence cookie.

My environment is I have one Virtual server and this virtual server (domain) have many Application in different server. So we choosing pool via irule like this.

When HTTP_request {           (don't mind syntax)
if [http_uri == abc] { pool abc}   pool abc have server CC,DD
else if [http_uri == dfg ] {pool dfg} Pool dfg have server XX,YY
else pool default { pool default}   pool default have server AA,BB
}

Example: when Client access www.domain.com , he will go to pool default and have cookie for AA or BB. But when client click link on that page to access www.domain.com/abc , he will go to pool abc, but now cookie information will change to Server CC/DD. And this problem will make client lose session with www.domain.com (he also lose session with www.domain.com/abc if he redirect or access other page because cookie information changed)

How Can I fix this? like store cookie for each pool (client have cookie_default for pool default and cookie_abc for pool abc so when he access www.domain.com and www.domain.com/abc , he won't lose session)

Thank you

3 Replies

  • Can this irule work? or I need to insert cookie in HTTP response or have to do another rule

        ltm rule /Common/irule_vs_choosepool {
        when HTTP_REQUEST {
       set uri [HTTP::uri]
       if { $uri starts_with "/agent" " } { 
          pool agent_pool
          persist cookie insert agent 0
       }
       elseif { $uri starts_with "/member" } { 
          pool member-pool
          persist cookie insert member 0
       }
       elseif { $uri starts_with "/employer" } { 
          pool employer-pool
          persist cookie insert employer 0
       }
        else {
          pool default-pool
     }
    
  • How Can I fix this? like store cookie for each pool (client have cookie_default for pool default and cookie_abc for pool abc so when he access www.domain.com and www.domain.com/abc , he won't lose session)

    isn't it default behavior?

    When you configure a cookie persistence profile to use the HTTP Cookie Insert or HTTP Cookie Rewrite method, the BIG-IP system inserts a cookie into the HTTP response, which well-behaved clients include in subsequent HTTP requests for the host name until the cookie expires. The cookie, by default, is named BIGipServer. The cookie is set to expire based on the time-out configured in the persistence profile. The cookie value contains the encoded IP address and port of the destination server.
    

    sol6917: Overview of BIG-IP persistence cookie encoding

    https://support.f5.com/kb/en-us/solutions/public/6000/900/sol6917.html
     configuration
    
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar
    ltm virtual bar {
        destination 172.28.24.10:80
        ip-protocol tcp
        mask 255.255.255.255
        persist {
            cookie {
                default yes
            }
        }
        profiles {
            http { }
            tcp { }
        }
        rules {
            qux
        }
        source 0.0.0.0/0
        source-address-translation {
            type automap
        }
        vs-index 39
    }
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux
    ltm rule qux {
        when HTTP_REQUEST {
            switch -glob [string tolower [HTTP::uri]] {
                    "/agent*" { pool foo1 }
                    "/member*" { pool foo2 }
                    default { pool default }
            }
    }
    }
    
     test
    
    [root@ve11c:Active:In Sync] config  curl -I http://172.28.24.10/agent/something
    HTTP/1.1 404 Not Found
    Date: Fri, 24 Apr 2015 04:34:59 GMT
    Server: Apache/2.2.3 (CentOS)
    Last-Modified: Sun, 09 Feb 2014 08:39:51 GMT
    ETag: "41879c-59-2a9c23c0"
    Accept-Ranges: bytes
    Content-Length: 89
    Content-Type: text/html; charset=UTF-8
    Set-Cookie: BIGipServerfoo1=1707657416.20480.0000; path=/
    
    [root@ve11c:Active:In Sync] config  curl -I http://172.28.24.10/member/something
    HTTP/1.1 404 Not Found
    Date: Fri, 24 Apr 2015 04:36:59 GMT
    Server: Apache/2.2.3 (CentOS)
    Content-Type: text/html; charset=iso-8859-1
    Set-Cookie: BIGipServerfoo2=1875429576.20480.0000; path=/
    
    [root@ve11c:Active:In Sync] config  curl -I http://172.28.24.10/something
    HTTP/1.1 404 Not Found
    Date: Fri, 24 Apr 2015 04:35:11 GMT
    Server: Apache/2.2.3 (CentOS)
    Last-Modified: Sun, 09 Feb 2014 08:39:51 GMT
    ETag: "41879c-59-2a9c23c0"
    Accept-Ranges: bytes
    Content-Length: 89
    Content-Type: text/html; charset=UTF-8
    Set-Cookie: BIGipServerdefault=1707657416.20480.0000; path=/
    
    
  • Hi Nitass ,

     

    Sorry I forgot to mention We use custom cookie name in cookie persist profile.

     

    I just found SOL9815 for solution of this issue and my method is the same as method "Specifying in the iRule a unique custom persistence cookie name for each pool"

     

    Problem is application still lose session. So I think we not explicit define pool selection good enough. So There must be some possible condition resulting in a pool selection that we don't know. I will go check the application again.

     

    Thank you very much