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...
Colin_Walker_12
Jul 14, 2008Historic F5 Account
Here'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
}
}
}
}
Basically this is the same iRule, except that it performs a host check, too. Basically, you set both domains to point to the VIP address. Then, when traffic comes in from site1.org with /forms at the start of the URI, it will do an HTTP redirect to site2.com while maintaining the exact same URI (we already know it contains forms, so we don't need to rebuild it or strip forms out or anything, we just keep the whole thing intact as is). It will then hit the same VIP, again, and process through the second half of the iRule, as it won't get caught by the Host check this time. Now it'll hit the pool logic portion that elah built for you, and everyone should be happy.
Make sense?
Colin
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