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

Milan_4483's avatar
Milan_4483
Icon for Nimbostratus rankNimbostratus
Oct 14, 2013

Pool Selection based on HOST and URI

Hello,

I am trying to figure out an irule for pool selection for the following scenario

I have 2 DNS entries pointing to the same public ip dns1.abc.com dns2.abc.com

For each of the above, i have 2 clients

dns1.abc.com/client1 dns1.abc.com/client2 dns2.abc.com/client1 dns2.abc.com/client2

Based on the Host/URI i want to point the user to apprpriate pool dns1client1 pool dns1client2 pool dns2client1 pool dns2client2 pool

Will the following irule work and is there a more efficient way of getting the desired result

when HTTP_REQUEST {

switch [ string tolower [HTTP::host]] 
{
"dns1.abc.com" { 

    switch -glob [ string tolower [HTTP::URI]]{
        "/client1" {pool dns1client1}
        "/client2" {pool dns1client2}
        }
        }
"dns2.abc.com" { 
    switch -glob [ string tolower [HTTP::URI]]{
        "/client1" {pool dns2client1}
        "/client2" {pool dns2client2}
        }
        }
}

}

1 Reply

  • I'd recommend this exact process. The only thing I might add is that you're using a "-glob" option in the switch but using static URIs. Will the request always be for "/client1", or will it perhaps have some URI data after it (ex. "/client1/foo/bar/blah")? If so, it'd be more appropriate to use ""/client1*" in the switch condition.