Forum Discussion
Irule 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.
irule 1:
when HTTP_REQUEST { set hostname [string tolower [HTTP::host]] set tops_uri [string tolower [HTTP::uri]] if { $hostname contains "topssit" } { pool topssit-http } if { ($hostname contains "topsstg") && ($tops_uri starts_with "/socket.io")} { pool topsstg-socket-pool } if { $hostname contains "topsstg" } { pool topsstg-pool } if { $hostname contains "topstrg" } { pool topstrg-pool } if { $hostname contains "topsfat" } { pool topsfat-prod-pool } }
Irule 2 called in vip Name:Tops url redirect
when HTTP_REQUEST { if {([HTTP::uri] equals "/") || ([HTTP::uri] equals "/tops")}{ HTTP::redirect "http://[HTTP::host]/tops/" } }
2 Replies
- Hannes_Rapp
Nimbostratus
Hello Habib,
Could you please wrap your iRule inside a code-block for better visibility?
Code Code ... Hi Habib,
I've optimized the iRules for you. Instead of chaining multiple
commands, you should use a single[if { $condition} then { action }]
command. Using the later would stop comparsion after the first match and would save some CPU cycles.[if { $condition} then { action } elseif { $condition2 } then { action }]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
* 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