Forum Discussion

nickzml_306327's avatar
nickzml_306327
Icon for Nimbostratus rankNimbostratus
Jan 17, 2017

Hash Persistence based on HTTP Header "SV" tag

Hello, I am looking for the way how to implement the hash persistence based on http header "SV" tag with iRule. We have one virtual server with few servers mapped to one pool.

 

Currently we are using the source address persistence method. but it is not effective.

 

Could someone give me a example of hash persistence with irule to achieve what we want to?

 

3 Replies

  • Then you're in the right forum. 🙂

    Must confess that I have not done this particular thing, but try this?

    First create this irule:

    when HTTP_REQUEST {
      if { [HTTP::header exists "sv"] } {
        persist uie [HTTP::header value "sv"]
      }
    }
    

    Then create a universal persistence profile and choose the irule you just created as "irule" in the configuration

    Assign the persistence profile to the virtual server.

    /Patrik

  • Worked like a charm. Here's how it looked like on my unit:

    curl -k -H "sv: test" -H "Host: www.mysite.com" https://VIP-IP/en/
    
    Sys::Persistent Connections
    universal  test  VIP-IP:443  SERVERIP:4000  (tmm: 0)
    Total records returned: 1
    
    The default timeout is 180 seconds. Are you sure you tested before that?
    

    If the sv header is set in the response as well as the request, please add an irule event from for

    when HTTP_RESPONSE
    like this:

    when HTTP_REQUEST {
      if { [HTTP::header exists "sv"] } {
        persist uie [HTTP::header value "sv"]
      }
    }
    
    when HTTP_RESPONSE {
      if { [HTTP::header exists "sv"] } {
        persist add uie [HTTP::header value "sv"]
      }
    }
    

    /Patrik