Forum Discussion
iRule: Direct request to specific server, but you use pool if that server is down not working.
- Oct 13, 2021
Hi Richard.
I suggest that you need to check pool member state before node choosing
when CLIENT_ACCEPTED {
if {[IP::addr [IP::client_addr] equals A.A.A.A] } {
if { [LB::status pool SERVICE_60006_pool member 1.1.1.1 60006] != up } {
pool SERVICE_60006_pool
}
else {
node 1.1.1.1 60006
}
}
elseif {[IP::addr [IP::client_addr] equals B.B.B.B] } {
if { [LB::status pool SERVICE_60006_pool member 2.2.2.2 60006] != up } {
pool SERVICE_60006_pool
}
else { node 2.2.2.2 60006
}
}
else {
pool SERVICE_60006_pool
}
}
So we went with the following in a test environment and it worked. I would prefer if its up to do something, instead of if its not up do something in your example. Only because our team is new to iRules and think my way is a little bit more clear for the casual reader. That being said your formatting and how to check the status made the difference. Thank you so much. As I type this I do see how your way is a better choice.If member is down, immediately go to the pool, instead of checking the rest of the iRule then defaulting to the available pool.
# Force A.A.A.A to go to 1.1.1.1
# Force B.B.B.B to go to 2.2.2.2
# Unless destination node is down
# All other clients will use pool
when CLIENT_ACCEPTED {
if { ([LB::status pool SERVICE_60006_pool_pool member 1.1.1.1 60006] eq "up") && [IP::addr [IP::client_addr] equals A.A.A.A] }
{ node 1.1.1.1 60006}
elseif { ([LB::status pool SERVICE_60006_pool_pool member 2.2.2.2 60006] eq "up") && [IP::addr [IP::client_addr] equals B.B.B.B] }
{ node 2.2.2.2 60006}
else {pool SERVICE_60006_pool_pool}
}
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