Forum Discussion
Brandon_Mason_3
Nimbostratus
Aug 24, 2006iRule for HTTP Response
If anyone could help us with a few examples of how to write an iRule to meet this requirement it would be greatly appreciated.
Here’s a rough requirement summary:
For an incoming http request for the uri:
http://www.yoursite.com/sample.js
IF the response to the request, returned by a server sitting behind the load balancer is:
a. NOT status 200 or
b. IS status 200 but NOT completed within X secs
THEN return this canned http response:
-- BEGIN OUTPUT --
/*
* Load Balancer
*/
array_variable = [];
-- END OUTPUT --
- Deb_Allen_18Historic F5 AccountThe rule logic would be something like this:
where the response is imbedded in the code with the HTTP::respond command as discussed here: http://devcentral.f5.com/Default.aspx?tabid=28&view=topic&forumid=5&postid=9523when RULE_INIT { set ::timeout 5 ; seconds } when HTTP_REQUEST { set reqTime [clock seconds] } when HTTP_RESPONSE { if {not ([HTTP::status] == 200) or \ [clock seconds] > [expr $reqTime + $::timeout]}{ HTTP::respond ... } } }
- Brandon_Mason_3
Nimbostratus
Thanks! This is great. Definitely gets us going. - John_Richmond_1
Nimbostratus
Using this rule, if one of my servers takes 10 seconds to process a request, do I get the fixed response after 10 seconds (time it takes the server to respond) or 5 seconds (the defined timeout)? The comments from http://devcentral.f5.com/Default.aspx?tabid=28&view=topic&forumid=5&postid=9663 seem ominous. - Deb_Allen_18Historic F5 Account
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