Custom error pages by way of iRule

    When presenting a load balanced pool of servers to a group of users, uptime and error handlings are always things to be kept in mind. Whether your user group is the internet at large or your internal sales team, no one likes to get a default timeout or a 404 error.


    With this simple rule you can enable custom error pages for an entire group of servers at once, without having to configure the webserver at all. This allows for a great amount of flexibility in migration or upgrade situations, as well as limiting the number of changes that need to be tracked on the pools of servers.


    The below rule first examines the HTTP_RESPONSE event to find the status of HTTP response. In this case, I’m searching for a 404 status code. If it finds the code(s) in question, it performs the action of your choosing. In this case, we’re just redirecting it to a static html error page hosted on another webserver that has some information to give the customer as to why they’re seeing this error, and perhaps when to expect things back up…that sort of thing.


when HTTP_RESPONSE { 
  if { [HTTP::status] eq "404" } { 
    redirect to "http://10.10.10.1/en_US/error.html" 
  } 
}


    As you can see, the time involved in a simple rule like this can easily be a fraction of the time it would take to configure multiple servers with the same custom error pages. Moreover, you have more control in this situation in the event that the webserver is down and/or not responding.


    This is just another way that the BIG-IP can help to build efficiency into your network and continue to help streamline the business processes built around your servers.

Published Aug 15, 2005
Version 1.0

Was this article helpful?

2 Comments

  • I am trying to implement a similar feature on our F5 but I don't understand how this is working. When my monitors detect that the pool members are all down the F5 just stops responding on the Virtual Server IP address so this rule never gets applied. Is there additional configuration necessary to make an iRule like this work within the virtual server or health monitor?
  • mrv's avatar
    mrv
    Icon for Nimbostratus rankNimbostratus

    In my opinion indication of 404 status by redirection (302) to existing page (Error page -200) is against the rule that URL should indicate rosource.

    In other words as long as resource doesnt exist, the error page should be dispalyed but also return 404 status.

     

    Your solution works in following way:

    Request -> 302 -> 200

    302 means resource moved, not 'not found'

     

    Is there a way to make forward (forward error page contents) instead of redirect?