Looking for best practices on creating iRules for pool members redirection
Hi,
I am new to F5 BIG-IP LTM and creating iRules. I came from the Citrix Netscaler world. Creating redirect policies seemed to be a lot easier on the Netscaler when using their content switching feature. With F5, you don't have the logical virtual servers for each pool members, it is all tied to one VIP using iRules. I haven't found an article that really references some best practices on how many number of lines or policies you can have in a single iRule.
My goal is to have a single VIP and use either 1 or multiple iRules to redirect different HTTP requests based on the host header information to different back end pool members. I don't plan on having hundreds of if statements for pool member redirection but I am wondering what limitations might be.
Here is a real basic example of what I am looking to achieve below on using the iRules to perform content switching. For every new app, I will append the HTTP_REQUEST with an if statement condition. Is there a better way to shorten what I have below? I wanted to use HTTP::uri so I can take advantage of the caching but could not get it to work using it. Will it still cache the request using HTTP::host? I know in the HTTP caching profile it referenced uri, that's why I am wondering if the host value will not be cacheable.
when HTTP_REQUEST {
if { [HTTP::host] equals "remotedesktop.host.com" } { pool remotedesktop-pool-443 persist source_add }
if { [HTTP::host] contains "blue" } { SSL::disable serverside pool blue-pool-9041}
if { [HTTP::host] contains "red" } { SSL::disable serverside pool red-pool-9051 }
if { [HTTP::host] contains "orange" } { SSL::disable serverside pool orange-pool-9081 }
if { [HTTP::host] contains "yellow" } { SSL::disable serverside pool yellow-pool-8080 }
if { [HTTP::host] contains "green" } { SSL::disable serverside pool green-pool-9051
} }