Forum Discussion

igor_'s avatar
igor_
Icon for Altocumulus rankAltocumulus
Apr 01, 2024
Solved

F5 Maintenance Page

Hi,

We are trying to set up a maintenance page in case of 503 error code, but it doesn't matter which code is received by the client it always gets a maintenance page, even if the code is 200 OK.

We are using this iRule"

when HTTP_REQUEST {
  HTTP::respond 503 content {
<HTML>
     <head>
        <title>Maintenance Page</title>
    </head>
    <body>
    <style>
    body {
    background-image: url("https://www.somesite.com/download/503.png");
    background-size: contain;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    }
    </style>
 </body>
</html> "Content-Type" "text/html" "Retry-After" "3600" "Connection" "Close"
 }
}

Thanks, 

Igor

  • Igor,

    The iRule command HTTP::respond is a command, not a condition.  You said that you want to respond with a maintenance page IF the response from the server is 503.  So you need to include that condition in your iRule.  Also, that condition, the server response code, cannot be known until we get a response form the server, so you will need to use the HTTP_RESPONSE event instead of the HTTP_REQUEST event.  Finally, the server response code is accessible via the HTTP::status iRule command
    It will look something like this:

    when HTTP_RESPONSE {
      if { [HTTP::status] eq "503" } {
        HTTP::respond 503 content { 
          your response content
          goes here
        }
      }
    }

     

    Hope that helps,

    JM

2 Replies

  • igor_ The reason for this is because the event you are defining is when and HTTP request comes in from the outside the F5 responds with the 503. If your intent is to tie this to some servers that are currently down you would need to do the following if you have a default pool associated to the virtual server.

    when CLIENT_ACCEPTED priority 500 {
    
       set DEFAULT_POOL [LB::server pool]
    
    }
    
    when HTTP_REQUEST priority 500 {
    
        if { [active_members [${DEFAULT_POOL}]] == 0 }{
            HTTP::respond 503 content {
                <HTML>
                <head>
                <title>Maintenance Page</title>
                </head>
                <body>
                <style>
                body {
                    background-image: url("https://www.somesite.com/download/503.png");
                    background-size: contain;
                    background-repeat: no-repeat;
                    background-attachment: fixed;
                    background-position: center;
                    height: 100vh;
                    width: 100vw;
                    overflow: hidden;
                }
                </style>
                </body>
                </html> "Content-Type" "text/html" "Retry-After" "3600" "Connection" "Close"
            }
        }
    
    }

     

  • Igor,

    The iRule command HTTP::respond is a command, not a condition.  You said that you want to respond with a maintenance page IF the response from the server is 503.  So you need to include that condition in your iRule.  Also, that condition, the server response code, cannot be known until we get a response form the server, so you will need to use the HTTP_RESPONSE event instead of the HTTP_REQUEST event.  Finally, the server response code is accessible via the HTTP::status iRule command
    It will look something like this:

    when HTTP_RESPONSE {
      if { [HTTP::status] eq "503" } {
        HTTP::respond 503 content { 
          your response content
          goes here
        }
      }
    }

     

    Hope that helps,

    JM