Forum Discussion
kevin_50596
Nimbostratus
Jul 10, 2008Multi-part Irule
Hello, I'm fairly new to writing iRules so I'm not sure exactly how to get this done. Any help would be greatly appreciated.
Here's some data to give you context for what I'm trying to do:
1. Any http request coming into this Virtual Server with a uri ending in "/forms" needs to be redirected to a second pool seperate from the default pool. All other http requests should go to the default pool.
2. If the second pool doesn't have any active nodes, a third pool must be selected and the http request must be redirected there.
There are two iRules I've found which I think will accomplish this, but I'm not sure how to combine them into a single iRule.
Here they are:
when HTTP_REQUEST {
if {[HTTP::host] contains "/forms"} {
pool SECOND_POOL
}
}
and
when CLIENT_ACCEPTED {
if {[active_members SECOND_POOL] < 1}{
pool THIRD_POOL
}
}
Thanks again for any help,
Kevin
- hoolio
Cirrostratus
Hi Kevin,when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: New request to [HTTP::uri]" Check if URI contains /forms if {[HTTP::uri] contains "/forms"} { log local0. "[IP::client_addr]:[TCP::client_port]: active members: [active_members SECOND_POOL]" Use the second pool if it has available members if {[active_members SECOND_POOL] > 0}{ pool SECOND_POOL } else { Second pool was down, so use the third pool pool THIRD_POOL } } }
- kevin_50596
Nimbostratus
Thanks for your help, man! I'll test everything out and reply with the outcome. - kevin_50596
Nimbostratus
Well, that worked wonderfully! Thanks again for your help. Unfortunately, and as always, the plot thickens. - hoolio
Cirrostratus
Can you list out the logic for what should be redirected to a new URL, what should be sent to a pool and what if anything you want rewritten as before the request is sent to the pool? If you can include the Host and/or URI checks you want to use, we can provide some more examples. - Colin_Walker_12Historic F5 AccountHere's some slightly updated code:
when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: New request to [HTTP::uri]" Check if URI contains /forms if {[HTTP::uri] starts_with "/forms"} { if { [HTTP::host ne "site2.com" } { HTTP::redirect "http://site2.com[HTTP::uri]" } else { log local0. "[IP::client_addr]:[TCP::client_port]: active members: [active_members SECOND_POOL]" Use the second pool if it has available members if {[active_members SECOND_POOL] > 0}{ pool SECOND_POOL } else { Second pool was down, so use the third pool pool THIRD_POOL } } } }
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