Forum Discussion
Kai_Wilke
Jan 12, 2016MVP
Hi Habib,
I've optimized the iRules for you. Instead of chaining multiple
[if { $condition} then { action }]
commands, you should use a single [if { $condition} then { action } elseif { $condition2 } then { action }]
command. Using the later would stop comparsion after the first match and would save some CPU cycles.
In addition I've integrated the abc.com requirement for your. Please review and tweak the desired actions for this URL as needed...
iRule1:
when HTTP_REQUEST {
set low_hostname [string tolower [HTTP::host]]
set low_uri [string tolower [HTTP::uri]]
if { $low_hostname contains "topssit" } then {
pool topssit-http
} elseif { ( $low_hostname contains "topsstg" ) and ( $low_uri starts_with "/socket.io" ) } then {
pool topsstg-socket-pool
} elseif { ( $low_hostname equals "abc.com" ) and ( $low_uri starts_with "/socket.io" ) } then {
pool abc_com-socket-pool
} elseif { $low_hostname contains "topsstg" } then {
pool topsstg-pool
} elseif { $low_hostname contains "topstrg" } then {
pool topstrg-pool
} elseif { $low_hostname contains "topsfat" } then {
pool topsfat-prod-pool
} else {
Rely on virtual server configuration
}
}
iRule2:
when HTTP_REQUEST {
if { ( [HTTP::uri] equals "/" ) or ( [HTTP::uri] equals "/tops" ) } then {
HTTP::redirect "http://[HTTP::host]/tops/"
}
}
Cheers, Kai