Sending custom error pages

If you are unfortunate enough to suffer a total failure of all of your webservers, all is not lost. Zeus Traffic Manager can host custom error pages for you, and this article shows you how! If all of the servers in a pool have failed, you have several options:

  • Each pool can be configured to have a 'Failure Pool'. This is used when all of the nodes in the primary pool have completely failed.
  • You may configure the traffic manager to send an HTTP Redirect message, directing your visitors to an alternate website.

However, you may reach the point where you've got nowhere to send your users. All your servers are down, so failure pools are not an option, and you can't redirect a visitor to a different site for the same reason.

In this case, you can use a third option:

  • You may configure a custom error page which is returned with every request.

Use the 'error file' setting in the Virtual Server configuration (prior to 6.0 this setting was per Pool) to achieve this. The error file should be placed in your ZEUSHOME/zxtm/conf/extra directory (copy it directly there or use the Conf.Extra Control API interface):

<html>
<head>
<title>Sorry</title>
<link rel="stylesheet" href="main.css" type="text/css" media="screen" >
</head>
<body>
<img src="logo.gif">
<h1>Our apologies</h1>
We're sorry. All of our operators are busy. Please try again later.
</body>
</html>

This HTML error page will now be returned whenever an HTTP request is received, and all of your servers are down.

Embedding images and other resources

Note that the HTML page has embedded images and stylesheets. Where are these files hosted? With the current configuration, the error page will be returned for every request.

You can use a little TrafficScript to detect requests for files referenced by the error page, and serve content directly from the conf/extra/ directory.

First, we'll modify the error page slightly to may it easier to recognize requests for files used by the error page:

<link rel="stylesheet" href="/.extra/main.css" type="text/css" media="screen">

and

<img src="/.extra/logo.gif">

Then, upload the main.css and logo.gif files, and any others you use, to the ZEUSHOME/zxtm/conf/extra/ directory.

Finally, the following TrafficScript request rule can detect requests for those files and will make the traffic manager serve the response directly:

# Only process requests that begin '/.extra/'
$url = http.getPath();
if( ! string.regexmatch( $url, "^/\\.extra/(.*)$" ) ) {
break;
} else {
$file = $1;
}
# If the file does not exist, stop
if( ! resource.exists( $file ) ) break;
# Work out the MIME type of the file from its extension
$mime = "text/plain";
if( string.regexmatch( $file, ".*\\.([^.]+)$" ) ) {
$ext = $1;
if ( $ext == "html" ) $mime = "text/html";
else if( $ext == "jpg" ) $mime = "image/jpeg";
else if( $ext == "png" ) $mime = "image/png";
else if( $ext == "gif" ) $mime = "image/gif";
else if( $ext == "js" ) $mime = "application/x-javascript";
else if( $ext == "css" ) $mime = "text/css";
}
# Serve the file from the conf/extra directory
$contents = resource.get( $file );
http.sendResponse( "200 OK", $mime, $contents, "" );

Copy and paste this TrafficScript into the Rules Catalog, and assign it as a request rule to the virtual server. Images (and css or js files) that are then copied into the $ZEUSHOME/zxtm/conf/extra can be refered to using /.extra/imagename.png. You will also be able to test your error page by browsing to /.extra/errorpage.html (assuming the file is called errorpage.html in the extra directory).

Crispin Flowerday [Zeus Dev Team] 11 November 2005 Bookmark with del.icio.us Post this article to Digg Post this article to reddit Post this article to Facebook Tweet this article 5 comments  

Comments:

This public messageboard is not a forum for technical support. To report technical support problems, please contact our dedicated Support team using the instructions at the bottom of this page.

Comment from: test [Visitor]
Under IE explore,there is 500 error when use this.
Permalink 07 March 2006 @ 06:23
Comment from: Crispin Flowerday [Zeus Dev Team]
Internet Explorer has a feature called 'friendly error pages'. It uses these when the error page it was provided is under 512 bytes.

You can disable these error pages from the Advanced tab of the 'Internet Options' dialogue. Although for a complete solution (that will work for your customers), ensure that your error page is greater than 512 bytes long.

Permalink 07 March 2006 @ 11:22
Comment from: Alexey [Visitor]
I wasn't able to find the option to set the HTTP redirect on failure, as suggested here:

"You may configure ZXTM to send an HTTP Redirect message, directing your visitors to an alternate website."

We use ZXTM-LB. Please advise on how this can be configured!
Permalink 20 December 2006 @ 01:00
Comment from: Owen Garrett [Zeus Dev Team]
If you were using ZXTM, you could use the following TrafficScript rule to send the redirect:

   if( pool.activeNodes() == 0 ) http.redirect( "http://knowledgehub.zeus.com" );

Of course, in ZXTM LB, you don't get TrafficScript, and the ZXTM RuleBuilder can't be used to implement this logic.

Instead, use the 'error_file' setting in the 'Connection Management' part of the Pool configuration. First, create a file called 'redirect-to-knowledgehub' (for example) in your conf/extra directory. It should contain the following HTTP header data:

   Location: http://knowledgehub.zeus.com/

Then edit your Pool configuration, go to the 'Connection Management' part, and configure 'error_file' to the name of the file you created.

You can easily test the configuration by setting all of the nodes in your pool to drain.
Permalink 20 December 2006 @ 09:47
Comment from: Owen Garrett [Zeus Dev Team]
From Twitter:

kevinfoote: ok. got my poor man's maintenance page setup done. using RuleBuilder and a maintenance pool http://www.tinyurl.com/ydkj7nn maybe some interest..

Thanks Kevin!
Permalink 04 January 2010 @ 10:39
Leave a comment ...
Your email address will not be displayed.
Your URL will be displayed.
This public messageboard is not a forum for technical support. To report technical support problems, please contact our dedicated Support team using the instructions at the bottom of this page.
Options:
 
(Line breaks become <br />)
(Set cookies for name, email & url)

Recently...

Other Resources