Forum Discussion
Using iRule to redirect F5 traffic
requests are being made for "; but you want to check the page ";, so [HTTP::host] will not cover what you want to check for. That is ONLY checking the host portion of the URL, and from your question you don't want to check that either, you want to check the content of the page ";
1- set a health check for your pool members to do a GET and look for "Offline" in the page.
2- use an iRule to determine the health of a pool and then re direct otherwise:
when CLIENT_ACCEPTED { set DEFAULT_POOL [LB::server pool] }
when HTTP_REQUEST {
if {[active_members $DEFAULT_POOL] == 0} {
HTTP::respond 301 Location "http://www.google.com"
} else {
pool $DEFAULT_POOL
}
}
- Jeremy_BrainerdMar 24, 2017
Nimbostratus
Soda Cup - I'm pretty new to iRules so I don't understand the Health check on how if that check fails I can redirect?
- Soda_Cup_148395Mar 27, 2017
Nimbostratus
the layer 7 health check will determine if content is available on a page or if the server is available at all. Your health checks for your pool can be completely different than what they members deliver to the users.
for your http health check send this- http://abc.home.com/home/a/b/Offline.html
leave the return string blank(any response passes) or look for a string that exists on the page like "Offline". For troubleshooting purposes I would just leave it blank
Then the f5 will monitor the members. For each connection to the VS the iRule will check if the number of available servers. If it is 0, then a redirect is send back to the client. If at least one pool member is available, it will balance to the default pool.
If you want to test create a test pool with the same members and a test VIP with the iRule.
- Jeremy_BrainerdMar 30, 2017
Nimbostratus
Soda Cup thanks for the response back and your response is clear now. However I am still struggling with the following Health Monitor as I need to check the status of the site for "Online" all is good continue to route traffic normal but when I see "Offline" I need to redirect traffic to a "Maintenance" page, I also have a HTTP Profile configured with a failback host to redirect traffic to a "Unavailable" page when all pool members are down. Here's what I have configured for the Health Monitor but it just doesn't seem to work.
Send String: GET /home/a/b/Offline.html\r\n\r\n
Receive String: Online
Receive Disable String: Offline
Any assistance in getting something put together to get me working results would be greatly appreciated.
- Soda_Cup_148395Mar 30, 2017
Nimbostratus
the quickest fix for that would be to remove the send and receive strings, and then either remove or rename the file when you want a pool member to be taken offline.
- Jeremy_BrainerdMar 30, 2017
Nimbostratus
Understood....but I don't want to take the pool members offline when Maintenance is happening I am being asked to just redirect traffic to a Maintenance page.
So keep in mine normal traffic is routing to http://abc.home.com I then need something to check here: http://abc.home.com/home/a/b/Offline.html
and if keyword "Offline" is detected on this site to redirect traffic to http://www.google.com
I've tried with a Monitor and iRules but nothing seems to work.
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