For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Yugandhar's avatar
Yugandhar
Icon for Nimbostratus rankNimbostratus
Jun 15, 2018

Pool Selection and Persistence using iRule

Hi,

Can we forward traffic to a particular pool based on the host(domain) section of the URL and apply persistence of 500ms using the below iRule.

when HTTP_REQUEST {

                if { [string tolower [HTTP::host]] equals "ad.test.xya.com" } {

                   pool xya_Test--pool

            } elseif { [string tolower [HTTP::host]] equals "bc.test.xya.com" } {

                   pool xya_Test--pool 

        } elseif { [string tolower [HTTP::host]] equals "vf.test.xya.com" } {

                   pool xya_Test--pool

                   persist 500

        } elseif { [string tolower [HTTP::host]] equals "lg.test.xya.com" } {

                   set clientip [IP::remote_addr]

                   pool xya_Test--pool

                   persist uie $clienip 500

        }else {            

           pool Default_VIP--pool 

        }

}

Thanks,

Yugandhar.

1 Reply

  • Yes it's possible to forward traffic to a specific pool based on the HTTP host header. As far as I know it's not possible to persist with a timeout specified in milliseconds. The timeout for persistence should be in seconds. For an iRule like this, it's better to use the switch function. See example below.

    when HTTP_REQUEST {
        switch [string tolower [HTTP::host]] {
            "ad.test.xya.com" {
                pool xya_Test--pool
            }
            "bc.test.xya.com" {
                pool xya_Test--pool
            }
            "vf.test.xya.com" {
                pool xya_Test--pool
            }
            "lg.test.xya.com" {
                pool xya_Test--pool
                persist source_addr
            }
            default {
                pool Default_VIP--pool
            }
        }
    }