F5 is upgrading its customer support chat feature on My.F5.com. Chat support will be unavailable from 6am-10am PST on 1/20/26. Refer to K000159584 for details.

Forum Discussion

Gill_32697's avatar
Gill_32697
Icon for Nimbostratus rankNimbostratus
Jan 20, 2015

sorry page redirect

Im trying to do a sorry page redirect for two conditions. First if the formatted page can be reached at the server then do the redirect, but is if there is a network failure and I cant reach the server, I need the second option "else or default" generic Sorry Page content loaded from the iRule itself. Im having problems with the brackets for the irule. If you can help me format it please...

 

when HTTP_REQUEST { if HTTP::respond 404 content {

 

HTTP::redirect "https://www.mysite.com/_default.htm" else { Apology Page We are sorry, but the site you are looking for is temporarily out of service If you feel you have reached this page in error, please try again. } }

 

2 Replies

  • shaggy's avatar
    shaggy
    Icon for Nimbostratus rankNimbostratus

    there are a few issues with the iRule as-is

     

    • In the description, you mentioned sending a redirect to the formatted page on the server if the formatted page can be reached, but in the example there is nothing verifying that the formatted page is available
    • The HTTP_REQUEST event cannot check for response content - HTTP_RESPONSE is more fitting
    • The syntax used to send the response is wrong

    To address the first point - I would create a monitor to check the status of the server's sorry-page and apply it to a new pool that only contains the sorry-server:

     

    ltm monitor http down_pool_mon {
        defaults-from http
        destination *:*
        interval 5
        timeout 16
        recv "200 OK"
        send "GET /_default.html HTTP/1.1\r\nHost: www.siterequest.com\r\nConnection: Close\r\n\r\n"
        time-until-up 0
        timeout 10
    }
    
    ltm pool down_pool {
        load-balancing-mode round-robin
        members {
            10.10.10.10:80 {
                address 10.10.10.10
                session monitor-enabled
                state up
            }
        }
        monitor down_pool_mon 
    }

    The associated iRule:

     

    when HTTP_RESPONSE {
      check server response code - if 404, perform sorry-activity
      if { [HTTP::status] contains "404"} {
            check availability of formatted-sorry-page on sorry-server
            ...by checking number of active members in down_pool
            if there is at least 1 active member, send redirect to sorry-page
            if no members in down_pool, send HTTP response from F5
            if { [active_members down_pool > 0 } {
                HTTP::redirect "http://www.siterequest.com/_default.html"
            } else {
                HTTP::respond 503 noserver content "Site Temporarily UnavailableWe are sorry, but the site you are looking for is temporarily out of service If you feel you have reached this page in error, please try again."
            }
      }
    }