21-Nov-2022 11:54
I am hoping this is a simple ask (nobbie in iRule scripting) , I am trying to create an irule that will route to specific pools based up on cookie header value.
For e.g.
Cookie header "Toggle"
Value "Y" or "N"
If toggle = Y goto Pool A
If toggle = N goto Pool B
Solved! Go to Solution.
21-Nov-2022 12:45 - edited 21-Nov-2022 12:52
Hi @viziony ,
Could you please try this :
when HTTP_REQUEST {
if { [HTTP::header "Toggle"] equals "YES" }{
pool pool_A
} else {
pool pool_B
}
}
#you can replace "equals" operator by "contains"
Try it and give me your feedback
hope this helps you.
28-Nov-2022 19:52
Hi @viziony - it looks like you gave a kudo to @Mohamed_Ahmed_Kansoh 's reply, so I'm going to mark that as the Accepted Solution to make it easier for someone else to see the answer. If that answer didn't help you, please let me know so I can change that status. 🙂
21-Nov-2022 11:57
Would it be something like this
when HTTP_REQUEST {
if { [HTTP::header "Toggle"] is "YES" }
{ pool pool_A }
else
{ pool Pool_B } }
21-Nov-2022 12:45 - edited 21-Nov-2022 12:52
Hi @viziony ,
Could you please try this :
when HTTP_REQUEST {
if { [HTTP::header "Toggle"] equals "YES" }{
pool pool_A
} else {
pool pool_B
}
}
#you can replace "equals" operator by "contains"
Try it and give me your feedback
hope this helps you.
22-Nov-2022 21:38
Hi Viziony,
You can also try,
==================================================
when HTTP_REQUEST{
if { [string tolower [HTTP::header values "Toggle"]] contains "YES"} {
pool pool_A
} else {
pool pool_B
}
}
==================================================
Here are few links for further ready:
K27803480: iRule for selecting a Pool or Pool-member based on HTTP Request URI contents.
https://support.f5.com/csp/article/K27803480
See more articles here
DevCentral Technical Articles iRules 101 - #05 - Selecting Pools, Pool Members, ...
https://community.f5.com/t5/technical-articles/irules-101-05-selecting-pools-pool-members-and-nodes/...
Clouddocs > > HTTP::header
https://clouddocs.f5.com/api/irules/HTTP__header.html
iRules Recipe 3: Pool and SNAT Selection by Host Header Value
https://community.f5.com/t5/technical-articles/irules-recipe-3-pool-and-snat-selection-by-host-heade...
https://community.f5.com/t5/codeshare/select-pool-based-on-http-host-header/ta-p/278199
Cooking with iRules - HTTP
https://readthedocs.org/projects/f5-agility-lab-template/downloads/pdf/latest/
HTH
28-Nov-2022 19:52
Hi @viziony - it looks like you gave a kudo to @Mohamed_Ahmed_Kansoh 's reply, so I'm going to mark that as the Accepted Solution to make it easier for someone else to see the answer. If that answer didn't help you, please let me know so I can change that status. 🙂