Technical Forum
Ask questions. Discover Answers.
cancel
Showing results forΒ 
Search instead forΒ 
Did you mean:Β 
Custom Alert Banner

maintenance page irule

cymru81
Altocumulus
Altocumulus

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 6

Samir
MVP
MVP

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.

cymru81
Altocumulus
Altocumulus

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"
}

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

cymru81
Altocumulus
Altocumulus

Can i ask why not ideal?

@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.

cymru81
Altocumulus
Altocumulus

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