Forum Discussion

bdheeraj's avatar
bdheeraj
Icon for Nimbostratus rankNimbostratus
Jul 26, 2024

F5 iRule to route traffic based on AS2 headers doesnt work

We are testing iRule on our F5 load balancer to route traffic based on the AS2 headers to different internal servers. We have created below iRule that inspects the HTTP headers and to directs the traffic accordingly. But we dont see traffic come to new pool member but goes to the existing pool member. can anyone help on this, this is a new requirement for our client.

 

when HTTP_REQUEST {
    # Check if the AS2 header exists
    if { [HTTP::header exists "AS2-From"] } {
        # Get the value of the AS2 header
        set as2_from [HTTP::header "AS2-From"]

        # Route based on the AS2 header value
        switch $as2_from {
            "INTGHXCOMS" {
                pool pool_partner1
            }
            "INTGHXEUCOMS" {
                pool pool_partner2
            }
            default {
                # Default pool if the AS2 header value does not match any known values
                pool pool_default
            }
        }
    } else {
        # Default pool if the AS2 header does not exist
        pool pool_default
    }
}

 

 

 

1 Reply

  • for pooldefault, simply set it as vserver's default pool.

    for the other pools, create local traffic policy such as below then bing the policy to the vserver.