Forum Discussion
GavinW_29074
Nimbostratus
Sep 27, 2011Catching Timeout and HTTP 502/503 Errors
Hi there,
Next question... One of the items that we've got set-up on our current Apache set-up is the ability to catch a 502 "Bad Gateway" and 503 "Service Unavailable" and return a 'Sorry, please try again' page.
We also set the Timeout value to be 30s, so that users aren't sat endlessly waiting for a page that may never return. Instead, they'll get the same 'Sorry, please try again' page after 30 seconds...
Currently, in Apache it's as simple as defining ErrorDocuments within a VHOST...
How can I accomplish the same with the F5?
I've set the Timeout value on the 'TCP' profile to be 30 seconds...
But not sure how to do the 'Sorry' pages...
Cheers
Gav
7 Replies
- Patrick_Chang_7Historic F5 AccountI would do something like the following:
when RULE_INIT {
set static::sorryPage {insert desired HTML here}
}
when HTTP_RESPONSE {
if { [HTTP::status] == 502 or [HTTP::status] =503 } {
clientside { HTTP::respond $static::sorryPage }
}
} - Michael_Yates
Nimbostratus
Hi GavinW,
The TCP Profile does not care about the availability of the "Content" being served by an application. It only checks to see that there is a "Service" listening on that port and responding. So as long as apache is alive and well the BigIP will keep sending traffic to it even if the application is in flames.
I would suggest an HTTP or HTTPS Health Check. You can set them to dig as deeply into the site as you wish to verify the availability of your application.
The F5 can either do a redirect or even provide a custom response itself when it sees an HTTP Status code that you tell it to look for. You can get more information on the HTTP::status command in the HTTP_RESPONSE event here:
http://devcentral.f5.com/wiki/iRules.HTTP__status.ashx
Hope this helps. - GavinW_29074
Nimbostratus
Michael/Patrick
That looks perfect for catching the 502/503 errors...
However how would I go about catching a long running session that time's out?
Cheers
Gav - Michael_Yates
Nimbostratus
Basically the same way. Just find out what HTTP::status code it is throwing and handle it the same way. The HTTP::status handler can capture any status code: 200, 301, 302, 500, etc.
I would advise caution in handling too much though and suggest sticking with the status codes that report on hard failures or explicit behaviors (300's or 500's). The 200's and 400's are part of normal application behavior. - hoolio
Cirrostratus
If you want to handle slow server responses, you could tune the TCP profile settings for triggering the LB_FAILED event:
LB_FAILED iRule event
http://devcentral.f5.com/wiki/iRules.lb_failed.ashx
sol7559: Overview of the TCP profile
http://support.f5.com/kb/en-us/solutions/public/7000/500/sol7559.html
Or you could use the after command in an iRule to set a timer in HTTP_REQUEST_SEND. The second example should give you a good start:
http://devcentral.f5.com/wiki/iRules.after.ashx
Aaron - hoolio
Cirrostratus
If you want to handle slow server responses, you could tune the TCP profile settings for triggering the LB_FAILED event:
LB_FAILED iRule event
http://devcentral.f5.com/wiki/iRules.lb_failed.ashx
sol7559: Overview of the TCP profile
http://support.f5.com/kb/en-us/solutions/public/7000/500/sol7559.html
Or you could use the after command in an iRule to set a timer in HTTP_REQUEST_SEND. The second example should give you a good start:
http://devcentral.f5.com/wiki/iRules.after.ashx
Aaron - GavinW_29074
Nimbostratus
Michael,
Agree that i dont want to over-complicate things... the main thing is to try and avoid a user sitting on a blank screen whilst the page is loading for more that 30 seconds... I'd rather throw a sorry page than have the user assume something else, or worse resubmit their request...
Hoolio: Cheers for that pointer, will have a read...
Cheers again
Gav
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
