Forum Discussion
habib_Khan
Nimbostratus
Jan 12, 2016Irule is not working. KIndly help.
I have a vip with below are the 2 irules confirgured for redirecting to different pools.
The irules are not working when url is tried with htt://abc.com/socket.io. Please correct if irules.
irul...
Kai_Wilke
MVP
Jan 12, 2016Hi 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
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects