Forum Discussion

Junzo's avatar
Junzo
Icon for Nimbostratus rankNimbostratus
Oct 20, 2021

iRule for sorry page and Maintenance page

Hi

Implemented 2 iRule to 1 Virtual Server.

Sorry.html and Maintenance.html page.

Both are working properly individually.

case1: server down -> sorry.html

case2: maintenance time -> maintenance.html

However, during the Maintenance period, once the server is down, no page show. just IE error "This page can't be displayed".

case3: maintenance time and server down -> (Expect) maintenance.html -> (result) IE error.

Can I get any suggestions? configuration or iRules.

iRule 1

when HTTP_REQUEST {
 set maintenance_start_time "0000";
 set maintenance_end_time "2359";
 set maintenance_day "Sunday";

 scan [clock format [clock seconds] -format {%A %k %M}] {%s %s %s} cur_day cur_hour cur_minute
 set cur_time ${cur_hour}${cur_minute}

if { ($cur_day eq $maintenance_day) &&
 ($cur_time >= $maintenance_start_time) &&
 ($cur_time <= $maintenance_end_time) } {
  HTTP::respond 200 ifile "/Common/maintenance.html"
 }
}

iRule 2

when HTTP_REQUEST {
 if { [active_members Pool_A] < 1 } {
 HTTP::respond 200 ifile "/Common/sorry.html" 
 }

Best Regards

  • Hello Junzo,

     

    Try this:

     

    when LB_FAILED {

     set maintenance_start_time "0000";

     set maintenance_end_time "2359";

     set maintenance_day "Sunday";

     

     scan [clock format [clock seconds] -format {%A %k %M}] {%s %s %s} cur_day cur_hour cur_minute

     set cur_time ${cur_hour}${cur_minute}

     

     if { ($cur_day eq $maintenance_day) &&

     ($cur_time >= $maintenance_start_time) &&

     ($cur_time <= $maintenance_end_time) } {

     HTTP::respond 200 ifile "/Common/maintenance.html"

     } else {

      HTTP::respond 200 ifile "/Common/sorry.html"

     }

    }

     

     

    • Junzo's avatar
      Junzo
      Icon for Nimbostratus rankNimbostratus

      Thank you for your suggestion.

      still doesn't work.. I try another iRule.

  • This is expected behaviour, as there are 2 matches for HTTP::respond event when server goes down during the scheduled maintenance. This will cause TCL error with multiple redirects and cause reset (RST) to the connection. You can combine both iRules in one and give SORRY page only when server is down out of maintenace window.

    when HTTP_REQUEST {
     set maintenance 1
     set maintenance_start_time "0000";
     set maintenance_end_time "2359";
     set maintenance_day "Sunday";
     
     scan [clock format [clock seconds] -format {%A %k %M}] {%s %s %s} cur_day cur_hour cur_minute
     set cur_time ${cur_hour}${cur_minute}
     
    if { ($cur_day eq $maintenance_day) &&
     ($cur_time >= $maintenance_start_time) &&
     ($cur_time <= $maintenance_end_time) } {
      set maintenance 0
      HTTP::respond 200 ifile "/Common/maintenance.html"
      return
     }
     
    when LB_FAILED {
    if { ([active_members Pool_A] < 1) and ($maintenance == 0) } {
      #log local0. "scheduled maintenance going on. no sorry page"
     } else {
     HTTP::respond 200 ifile "/Common/sorry.html" 
     }
    } 
  • I thought of another idea of using event disable command to stop executing other iRules if maintenance page iRule is triggered. Use higher priority for sorry page iRule or move it to the top.

    when HTTP_REQUEST priority 100  {
     set maintenance_start_time "0000";
     set maintenance_end_time "2359";
     set maintenance_day "Sunday";
     
     scan [clock format [clock seconds] -format {%A %k %M}] {%s %s %s} cur_day cur_hour cur_minute
     set cur_time ${cur_hour}${cur_minute}
     
    if { ($cur_day eq $maintenance_day) &&
     ($cur_time >= $maintenance_start_time) &&
     ($cur_time <= $maintenance_end_time) } {
      HTTP::respond 200 ifile "/Common/maintenance.html"
     event disable all
     }
    }
  • Junzo's avatar
    Junzo
    Icon for Nimbostratus rankNimbostratus

    Hi SanjayP,

     

    Thank you for your suggestions! let me test and share the rusult here soon.