Forum Discussion

Benjamin_9120's avatar
Benjamin_9120
Icon for Nimbostratus rankNimbostratus
Jun 08, 2010

Return the custom error page to client

My customer want return the customization error page to client if all server is down that this virtual, and this page need built-in LTM.

 

How to achieve this feature use irules?

 

6 Replies

  • You have several different options, I haven't included all of them... You can find more in the CodeShare:

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/CodeShare.htmlMisc

     

     

    Rather than sending the status codes you can set the response type to whatever status code you wish and redirect the traffic to a specified location:

     

    
    when HTTP_RESPONSE {
         if { [HTTP::status] == "403" } {
             HTTP::respond 200 Loccation "http://www.customerrorpage.com"
         }
         elseif { [HTTP::status] == "404" } {
             HTTP::respond 200 Loccation "http://www.customerrorpage.com"
         }
    }
    

     

     

    Rather than sending the status codes you can use a 301 redirect:

     

    
    when HTTP_RESPONSE {
         if { [HTTP::status] == "403" } {
             HTTP::redirect "http://www.customerrorpage.com"
         }
         elseif { [HTTP::status] == "404" } {
             HTTP::redirect "http://www.customerrorpage.com"
         }
    }
    

     

     

    Rather than sending the status codes you send a custom response:

     

    
    when HTTP_RESPONSE {
         if { [HTTP::status] == "403" }
         HTTP::respond 200 content "Forbidden
        
        
        
        Website Error:  Forbidden
        NOTICE: Website has experienced an error.
        "
     }
         elseif { [HTTP::status] == "404" } {
                              HTTP::respond 200 content "File Not Found
        
        
        
        Website Error:  File Not Found
        NOTICE: Website has experienced an error.
        "
         }
    }
    
  • The first two seem to have blown up during the first post:

    
    when HTTP_RESPONSE {
         if { [HTTP::status] == "403" } {
             HTTP::respond 200 Loccation "http://www.customerrorpage.com"
         }
         elseif { [HTTP::status] == "404" } {
             HTTP::respond 200 Loccation "http://www.customerrorpage.com"
         }
    }
    

    Rather than sending the status codes you can use a 301 redirect:

    
    when HTTP_RESPONSE {
         if { [HTTP::status] == "403" } {
             HTTP::redirect "http://www.customerrorpage.com"
         }
         elseif { [HTTP::status] == "404" } {
             HTTP::redirect "http://www.customerrorpage.com"
         }
    }
    
  • Thanks for all helps。 But,those error code was returned form web server, all server is down,Who returns the error code at this time?
  • Are you tring to return an error page when all servers in your pool are down?

     

    If so see

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/LTMMaintenancePage.html

     

  • The link should be -

     

    http://devcentral.f5.com/wiki/d...ePage.html
  • Not sure why the link is not coming out correctly.

     

    search for maintenance page in devcentral and it is the first hit

     

    /iRules/LTMMaintenancePage.html