Forum Discussion

VinodM_322332's avatar
VinodM_322332
Icon for Nimbostratus rankNimbostratus
May 30, 2017

iRule for routing request when multiple cookies are present

I am really a novice with F5 and hence this question. We have an application for which the client sends multiple (two) cookies from which we need F5 to route based on the first one instead of the second.

How can I achieve this using irule ? For instance, I need F5 to route to node1 instead of 2:

Request sent 100 bytes of Cookie data:

JSESSIONID=4C07E6A52AA31DABD0E8F64EB87C1C3E.node1
JSESSIONID=3B51D3CE40727431ECC23A44080340F6.node2

Response sent 80 bytes of Cookie data: Set-Cookie: JSESSIONID=3B51D3CE40727431ECC23A44080340F6.node2; Path=/policyserver/; HttpOnly

1 Reply

  • Anesh's avatar
    Anesh
    Icon for Cirrostratus rankCirrostratus

    Try the below:

    when HTTP_REQUEST {
    
       log local0. "Cookie: [HTTP::cookie value "JSESSIONID"]"
       if { [HTTP::cookie value "JSESSIONID"] ne "" }{
          switch [HTTP::cookie value "JSESSIONID"] {
             "4C07E6A52AA31DABD0E8F64EB87C1C3E.node1" {
                node node-A
                log local0. "using node-A"
             }
             "3B51D3CE40727431ECC23A44080340F6.node2" {
                node node-B
                log local0. "using node-B"
             }
    
       
          }
       }
    }