Forum Discussion
Will this irule work okay to "Patch" a messed up web application
I am running version 10.2 and unfortunately there is a little problem with a "Cloud" Application that consists of several front end web servers that talk to a few db servers in the back.Every so often some kind of bad data hits the front end customer facing web servers returning a nasty confusing 500 error that looks like a BSOD message on steroids.
(If a user retries a few times they will get the output that is supposed to be correct)
So I thought maybe the F5 could save the day using it like a virtual software patch for now and hide the "500 error" from the end users
Anytime a pool member returns an error 500 just select the next pool member in line and see if it is okay. If it is, then just spit out the correct website.
And let the programmers work in peace while they fix the issue.
when CLIENT_ACCEPTED {
set variable def_pool to pool name queried by the LB command.
set the variable retries to zero
set def_pool [LB::server pool]
set retries 0
}
when HTTP_REQUEST {
set request_headers [HTTP::request]
}
when LB_SELECTED {
if { $retries >= 1 } {
LB::mode rr
LB::reselect pool $def_pool
}
}
when HTTP_RESPONSE {
if { [HTTP::status] starts_with "5" } {
incr retries
log local0. "5xx error caught: retry $retries out of [active_members [LB::server pool]]"
if { $retries < [active_members $def_pool] } {
HTTP::retry $request_headers
}
}
}
The command LB::reselect pool will advance the pointer down to the next available load balancer
LB::mode rr
LB::mode reselect
using mode rr to force into roundrobin mode because its set to least connections, hop to next server in line.
- nitassEmployeethis is mine.
[root@iris:Active] config b virtual bar list virtual bar { snat automap pool foo destination 172.28.17.33:http ip protocol tcp rules myrule profiles { http {} tcp {} } } [root@iris:Active] config b pool foo list pool foo { members { 74.125.235.48:http {} 172.28.17.22:http {} } } [root@iris:Active] config b rule myrule list rule myrule { when CLIENT_ACCEPTED { set def_pool [LB::server pool] set retries 0 } when HTTP_REQUEST { set request_headers [HTTP::request] log local0. "$request_headers" } when LB_SELECTED { log local0. "[LB::server addr]" } when HTTP_RESPONSE { log local0. "[IP::server_addr]:[TCP::server_port] [HTTP::status]" if {[HTTP::status] starts_with "5"} { incr retries log local0. "5xx error caught: retry $retries out of [active_members [LB::server pool]]" if { $retries < [active_members $def_pool] } { HTTP::retry $request_headers } } } } [root@iris:Active] config curl -I http://172.28.17.22 HTTP/1.0 500 Internal Server Error Server: BigIP Connection: Keep-Alive Content-Length: 0 [root@iris:Active] config curl -I http://172.28.17.33 HTTP/1.1 200 OK Date: Sat, 05 Nov 2011 01:32:05 GMT Expires: -1 Cache-Control: private, max-age=0 Content-Type: text/html; charset=ISO-8859-1 Server: gws X-XSS-Protection: 1; mode=block X-Frame-Options: SAMEORIGIN Transfer-Encoding: chunked [root@iris:Active] config tail -f /var/log/ltm Nov 5 09:29:22 local/tmm info tmm[1609]: Rule myrule : HEAD / HTTP/1.1 User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Host: 172.28.17.33 Accept: */* Nov 5 09:29:22 local/tmm info tmm[1609]: Rule myrule : 172.28.17.22 Nov 5 09:29:22 local/tmm info tmm[1609]: Rule myrule : 172.28.17.22:80 500 Nov 5 09:29:22 local/tmm info tmm[1609]: Rule myrule : 5xx error caught: retry 1 out of 2 Nov 5 09:29:22 local/tmm info tmm[1609]: Rule myrule : HEAD / HTTP/1.1 User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Host: 172.28.17.33 Accept: */* Nov 5 09:29:22 local/tmm info tmm[1609]: Rule myrule : 74.125.235.48 Nov 5 09:29:22 local/tmm info tmm[1609]: Rule myrule : 74.125.235.48:80 200
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