Forum Discussion
irule not functioning
I am using below irule for switching connection between pools depending on request. Its not working as needed. Need help.
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 equals "topsuat" ) and ( $low_uri starts_with "/socket.io" ) } then { pool topsuat-socket-pool } elseif { ( $low_hostname contains "topsstg" ) and ( $low_uri starts_with "/socket.io" ) } then { pool topsstg-socket-pool } elseif { ( $low_hostname equals "topssit" ) and ( $low_uri starts_with "/socket.io" ) } then { pool topssit-socket-pool } elseif { ( $low_hostname equals "topsstrg" ) and ( $low_uri starts_with "/socket.io" ) } then { pool topstrg-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 } }
Thanks in advance..
6 Replies
- Josiah_39459Historic F5 AccountPlease give some more information regarding "not working", for example error messages, tpcdump findings, etc. Also explain what you are trying to do with the irule.
- Hi Habib, I'm afraid that you still have issues with your iRule. Your current syntax looks valid to me. So please post some details whats going wrong with this iRule? Cheers, Kai (Your previous post: https://devcentral.f5.com/s/feed/0D51T00006j2nP3SAI)
Hi Habib,
just noticed, that the ordering of your iRule is little faulty. You have to use the most restrictiv condition before the less restrictive conditions, otherwise then later conditions wouldn't trigger...
when HTTP_REQUEST { set low_hostname [string tolower [HTTP::host]] set low_uri [string tolower [HTTP::uri]] if { ( $low_hostname equals "topsuat" ) and ( $low_uri starts_with "/socket.io" ) } then { pool topsuat-socket-pool } elseif { ( $low_hostname contains "topsstg" ) and ( $low_uri starts_with "/socket.io" ) } then { pool topsstg-socket-pool } elseif { ( $low_hostname equals "topssit" ) and ( $low_uri starts_with "/socket.io" ) } then { pool topssit-socket-pool } elseif { ( $low_hostname equals "topsstrg" ) and ( $low_uri starts_with "/socket.io" ) } then { pool topstrg-socket-pool } elseif { $low_hostname contains "topsfat" } then { pool topsfat-prod-pool } elseif { $low_hostname contains "topsstg" } then { pool topsstg-pool } elseif { $low_hostname contains "topssit" } then { pool topssit-http } elseif { $low_hostname contains "topstrg" } then { pool topstrg-pool }Note: In addition I would recommend to check the host and pool names. You have "topsuat" (for
) but "topsfat" (for/socket.io
) and also a slightly mixed naming convention for the pool names which may cause additional confusion. Also check your/*
andcontains
. Sometimes you're using one and sometimes the other...equalsCheers, Kai
- habib_Khan
Nimbostratus
Kai.. Actually when end user from internet try topsuat.xyz.com/socket.io or topssit.xyz.com/socket.io or topstrg.xyz.com/socket.ion try they should get a CDN response code. in this case only topsstg is working. checked all pools are up and fine. i can see irule stats increasing. Didnt do a tcpdump as basic http connection is working but not when we have /socket.io. Kindly let me know if more information is needed. you have always been so supportive for me. Thanks in advance. - habib_Khan
Nimbostratus
Kai,
- I changed and tried , no luck. Kindly make help me make this irule. I tried the below one as well, but no luck. when HTTP_REQUEST { switch [string tolower [HTTP::host]] { "topssit-http" { if { [string tolower [HTTP::uri]] contains "/socket.io" } { pool topssit-socket-pool } else { pool topssit-http } } "topsstg-pool" { if { [string tolower [HTTP::uri]] contains "/socket.io" } { pool topsstg-socket-pool } else { pool topsstg-pool } } "topstrg-pool" { if { [string tolower [HTTP::uri]] contains "/socket.io" } { pool topstrg-socket-pool } else { pool topstrg-pool } } "topsuat-http" { if { [string tolower [HTTP::uri]] contains "/socket.io" } { pool topsuat-socket-pool } else { pool topsuat-http } } } }
- nitass
Employee
I changed and tried , no luck. Kindly make help me make this irule. I tried the below one as well, but no luck.
i wonder whether right condition is not triggered or it is but packet is not forwarded correctly.
to check whether condition is triggered correctly, you may put some logging command in the irule. to check whether packet is forwarded properly, you may try tcpdump.
also, just in case you have not seen this.
sol9800: Using an iRule to load balance HTTP requests to multiple pools
https://support.f5.com/kb/en-us/solutions/public/9000/800/sol9800.html
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