Forum Discussion

Domai_23823's avatar
Domai_23823
Icon for Nimbostratus rankNimbostratus
Dec 01, 2017

Maint page irule help

Hello I am trying to come up with a iRule for maint page. The requirement is -

  • The page should be displayed when all the servers in the pool are down.
  • The servers will be patched and will be rebooted one at a time and will be tested. During testing I need the users from one ip range to access the site but the maint page should be displayed for all the other users.

The below is what I came up with so far...with errors ofcourse..where am I going wrong?

when HTTP_REQUEST { 
    if { [active_members [LB::server pool]] == 0 } {
     HTTP::respond 200 content [ifile get "Maintenance_html"] noserver "Cache-Control" "no-store, no-cache" 
    return 
    }
}
      elseif { [active_members [LB::server pool]] > 0 } {
         check if client access from internal subnet
        if { [IP::addr [IP::client_addr]/8 equals 10.0.0.0] } {
            pool http_80
        } else {
            switch [HTTP::uri] {
        default { HTTP::respond 200 content [ifile get "Maintenance_html"] noserver "Cache-Control" "no-store, no-cache"
        }
      }
        }    
    } 
}

4 Replies

  • Small modification made. Please try.

    when HTTP_REQUEST { 
        if { [active_members [LB::server pool]] == 0 } {
        HTTP::respond 200 content [ifile get "Maintenance_html"] noserver "Cache-Control"   "no-store, no-cache"
        return --Optional
    }
      elseif { [active_members [LB::server pool]] > 0 } {
         check if client access from internal subnet
        if { [IP::addr [IP::client_addr]/8 equals 10.0.0.0] } {
            pool http_80
        } else {
            HTTP::respond 200 content [ifile get "Maintenance_html"] noserver "Cache-Control" "no-store, no-cache"
            }    
         } 
    }
    
    • Domai's avatar
      Domai
      Icon for Altostratus rankAltostratus

      That is it perfect thank you.

       

    • Samir_Jha_52506's avatar
      Samir_Jha_52506
      Icon for Noctilucent rankNoctilucent

      can vote if irule solve ur purpose, so other can also refer. Thanks

       

  • Update to f5_rock’s updated iRule to remove duplication, also you don’t need the else and pool http_80 lines if you are using the default pool assigned to the virtual server.

    when HTTP_REQUEST {
         Pool members is less than 0 or client IP is not in subnet 10.0.0.0/8 return maintenance page
        if {[active_members [LB::server pool]] < 1 || [IP::addr [IP::client_addr]/8 ne 10.0.0.0]} {
            HTTP::respond 200 content [ifile get "Maintenance_html"] noserver "Cache-Control"   "no-store, no-cache"
        } else {
            pool http_80
        } 
    }