Forum Discussion

cymru81's avatar
cymru81
Icon for Altocumulus rankAltocumulus
Sep 27, 2023

maintenance page irule

Hi, id like to force all traffic to hit a maintenance page irule regardless of pool member status, i have the following but how can i write this without the "if" so it will disaply everytime?

when HTTP_REQUEST {
if { [active_members [LB::server pool]] == 0 } {
HTTP::respond 200 content "
<html>
<head>
<title>Under maintenance</title>
</head>
<body>
We are ndergoing maintenance. Please try again later. 
</body>
</html>
"
}
}

Thanks in advance 🙂

6 Replies

  • The if command evaluates active_members [LB::server pool] as an expression (in the same way that expr evaluates its argument). The value of the expression must be a boolean (a numeric value, where 0 is false and anything is true, or a string value such as true or yes for true and false or no for false); if it is true then body1 is executed by passing it to the Tcl interpreter. Otherwise expr2 is evaluated as an expression and if it is true then body2 is executed, and so on.

    Without if i don't granular options available.

  • thanks for responding, i changed it to this and it now works as id hoped:

    when HTTP_REQUEST {
    HTTP::respond 503 content \
    "<HTML><head><title>Maintenance page</title></head><body>
    <p> Our website is undergoing maintenance. Please try again later.
    <p>Thank you for your patience. </p>
    </body>
    </html>" "Content-Type" "text/html" "Retry-After" "3600" "Connection" "Close"
    }

    • Samir's avatar
      Samir
      Icon for MVP rankMVP

      Good. If all purpose is getting solved then no issue but its not ideal in granular way.

    • Paulius's avatar
      Paulius
      Icon for MVP rankMVP

      cymru81 The reason your way isn't ideal is because you want the maintenance page to come up under specific circumstances rather than something that you have to log into the F5 and change every time you want it to display. If you base the maintenance page on status of pool members then it would always come up when the pool members are not available, a true maintenance or down situation, rather than it always being displayed which means anyone that goes to your website would see this page rather than the website unless you manually remove the iRule every time you want the page to go away.

  • ah ok that makes sense, thanks for taking the time to respond.