Forum Discussion
Narendra_26827
Jul 08, 2011Nimbostratus
iRule to redirect request to another node if HTTP response is 404
Hi,
I want to create an iRule in which if i get an HTTP 404 response from a node in the pool i will be able to break the IP persistence and pass it to another node in the pool and for next r...
hooleylist
Jul 08, 2011Cirrostratus
Hi Narenda,
You could call HTTP::retry from HTTP_RESPONSE if the status is a 404. I'm not sure about clearing the persistence record though. I wonder if you could call persist none if $retries > 0 and then call persist again with the persistence method you're using.
Here's a rough example to start with:
when CLIENT_ACCEPTED {
set retries 0
}
when HTTP_REQUEST {
Don't retry requests with a payload as we don't
want to have to collect every payload to retry 404 responses
switch [HTTP::method] {
"GET" -
"HEAD" {
set request_headers [HTTP::request]
}
default {
set request_headers ""
}
}
}
when HTTP_RESPONSE {
if {$request_headers ne "" && $retries < [active_members [LB::server pool]]}{
switch [HTTP::status] {
404 {
incr retries
HTTP::retry $request_headers
}
}
}
}
Aaron
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