Forum Discussion

Rich101's avatar
Rich101
Icon for Nimbostratus rankNimbostratus
Aug 05, 2015

Traffic Policies - how to use different cookies for each pool

Hi,

 

I've done some digging around but can't find much detail on this.

 

We have a situation where we have several pools behind a single VS and are using a traffic policy to direct to the correct pool based on URI. Each pool has multiple servers, and a user would typically access multiple pools in one session. The trouble we have is that the user needs to persist to the same server in each of the pools for the session. Using a normal cookie persistence profile won't work as there is only a single cookie inserted, with the value being overwritten each time the user is directed to a different pool.

 

I've looked at the various cookie options in the traffic policy but haven't been able to figure anything out.

 

Anyone have any ideas?

 

Thanks,

 

10 Replies

  • What type of cookie persistence are you using? The default cookie persistence will indeed present a separate cookie for each pool that a user is sent to based on policy. The cookie name is based on the selected pool, so multiple pools = multiple cookies.

    BIGipServermy-pool-a=33572362.20480.0000
    BIGipServermy-pool-b=33572364.20480.0000
    
  • Hi Kevin,

     

    Thanks for your reply. We have assigned a single user created cookie persistence profile to the VS. This doesn't allow for a different cookie name to be inserted depending on which pool is targetted.

     

    How do you config the policy to insert a different cookie for each pool?

     

    Thanks,

     

  • Hi Kevin,

     

    I've just checked using the default cookie profile and get the results that you mention. However, the same as your results the cookie is in the form 'BIGipServerx-x'. This cookie name has not been acceptable to us for some time due, so we need a custom one with a user create name.

     

    Is it possible to replicate this behaviour on user created profiles?

     

    Thanks,

     

  • It is certainly possible, but understand that you'll have to code your own persistence mechanism with an iRule. There's no configuration option to reproduce the behavior of the default cookie persistence naming convention.

     

  • Hi Kevin,

     

    Ok thanks for confirming. We thought this was looking like the only solution. It's something that we ideally want to avoid.

     

  • Hi,

    In irule, you can assign a different cookie name.

    In policies, you can create a TCL variable...

    So with these two informations, you can create a generic irule like:

    when HTTP_REQUEST {
        if {([info exists "CookieName"])} {
            persist cookie insert $CookieName 0
        }
    }
    

    And Assign the desired cookie name in the value of CookieName variable in Policy:

    ltm policy Cookie_name {
        controls { forwarding }
        requires { http }
        rules {
            cookietest {
                actions {
                    0 {
                        tcl
                        set-variable
                        expression foo
                        name CookieName
                    }
                }
                ordinal 1
            }
        }
        strategy first-match
    }
    
  • Hi Stanislas,

     

    Thanks for your reply, sounds interesting. Would we just need to create individual iRules for inserting different cookies (one for each service/pool), and then call them as appropriate from the policy?

     

  • Hi,

    the goal was to create a generic irule which can be used for every VS, every URLs...

    the requirements of this irule are:

    • persistence cookie enabled on the VS (
      persist cookie insert
      only match if cookie persistence is default persistence profile of the VS)
    • Policy set-variable action with name "CookieName"

    As Policy event HTTP REQUEST is processed before irules event HTTP_REQUEST, variable assigned in policies are matched by the irule.

  • Hi Stanislas,

     

    Thanks for sharing this information. If I understand correctly (I am not sure...) the cookie name seen/set by the irule would be "foo" based on what you have defined in the policy?

     

    ltm policy Cookie_name { controls { forwarding } requires { http } rules { cookietest { actions { 0 { tcl set-variable expression foo name CookieName } } ordinal 1 } } strategy first-match }