cancel
Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.

Using an iRule to display a maintenance page when the pool is down

luyenntk50db
Nimbostratus
Nimbostratus

I have configured to redirect Virtual server to maintenance page when all pool member down.

I have configured below guide:

https://support.f5.com/csp/article/K14702105

When i used irule below, Irule has completed configuration.

when HTTP_REQUEST { 

   if { [active_members [LB::server pool]] == 0 } { 

     HTTP::respond 200 content "

      <html>

         <head>

            <title>Maintenance Page</title>

         </head>

         <body>

            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.

         </body>

      </html>

      "

   }

}

But, when I edited as below, irule has not change:

when HTTP_REQUEST { 

  if { [active_members [LB::server pool]] == 0 } {

   HTTP::respond 200 content "

   <html>

     <head>

      <title>Maintenance Page</title>

     </head>

     <body>

     <article>

       <center><h1 style="color: #000;">

      Xin lỗi quý vị, hệ thống đang được bảo trì. Xin quý vị quay lại sau khi bảo trì hoàn tất.</h1> <center>

      <div>

    <center><h1 style="color: #000;">Xin trân trọng cảm ơn!.<p></p><center>

    </center></h1></center></div>

     <article>

     </body>

   </html>

   "

  }

}

Errors as below:

 

 

0691T00000BU72SQAT.jpg

Pls guide me!

3 REPLIES 3

iaine
MVP
MVP

Hi

 

Try changing the " " to group the HTML to { } braces instead as per the error. Suspect the " in the style lines are causing a conflict.

 

when HTTP_REQUEST {   if { [active_members [LB::server pool]] == 0 } {   HTTP::respond 200 content {   <html>   <head>   <title>Maintenance Page</title>   </head>   <body>   <article>   <center><h1 style="color: #000;">   Xin lỗi quý vị, hệ thống đang được bảo trì. Xin quý vị quay lại sau khi bảo trì hoàn tất.</h1> <center>   <div>   <center><h1 style="color: #000;">Xin trân trọng cảm ơn!.<p></p><center>   </center></h1></center></div>   <article>   </body>   </html>   }   }   }

 

Thanks for  ,

I changed belong as you. But irule failed.

0691T00000BUUOvQAP.jpg

iaine
MVP
MVP

OK - so you could either move your html code to a variable and then make a call to it like this

 

when RULE_INIT {   set static::sorry_code { <html> <head> <title>Maintenance Page</title> </head> <body> <article> <center><h1 style="color: #000;"> Xin lỗi quý vị, hệ thống đang được bảo trì. Xin quý vị quay lại sau khi bảo trì hoàn tất.</h1> <center> <div> <center><h1 style="color: #000;">Xin trân trọng cảm ơn!.<p></p><center> </center></h1></center></div> <article> </body> </html>     }   }     when HTTP_REQUEST { if { [active_members [LB::server pool]] == 0 } { HTTP::respond 200 content $static::sorry_page } }

...or you could try moving the html code to an iFile - https://clouddocs.f5.com/api/irules/iFile.html - if there are any strange characters in the html code that is causing a conflict then this method should resolve these issues