Forum Discussion

DineshVM_265886's avatar
DineshVM_265886
Icon for Altostratus rankAltostratus
Jan 24, 2017

Persist cookie serverID iRule

I want write an equivalent iRule for a Brocade load balancer Content Switching rule. Below is the CSW rule in Brocade. Basically the rule is to search for the Server ID in the Cookie header and persist the connection on that cookie header. Any equivalent iRule for this would be greatly appreciated.

 

csw-rule "sticky" header "cookie" search "ServerID="

 

csw-policy "vip"

 

match "sticky" persist offset 0 length 4 group-or-serverid

 

3 Replies

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    Is this your complete config from Brocade? Or is this meant to be same as described in "

     

  • This is the full Brocade rule. I was able to build the iRule for the other CSW rules below. But I couldn't find an equivalent iRule for the one I mentioned in the actual question.

     

    csw-rule "path" url equals "/"

     

    csw-rule "sticky" header "cookie" search "ServerID="

     

    csw-policy "vip"

     

    match "path" redirect "*" "/xyz" ssl

     

    match "sticky" persist offset 0 length 4 group-or-serverid

     

    default forward 1

     

    default rewrite insert-cookie "ServerID" " * " " * " 60

     

    I thought the iRule would look something like the below. I am not sure if the below one is right. But still working on putting together all the pieces.

     

    when HTTP_REQUEST {

     

    if { [HTTP::uri] equals "/" }{

     

    HTTP::redirect "https://[HTTP::host]/arch" }

     

    elseif { [HTTP::header "cookie"] equals "ServerID=" } {

     

    persist cookie

     

    }

     

    else {

     

    pool default_pool

     

    HTTP::cookie insert ServerID

     

    } }

     

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    It seems to me that apart from the redirect, which you can set up a traffic policy for, a default cookie persistence profile will do the job, although a dedicated persistence profile with a unique cookie name is the recommended practice.