IRULE to redirect the traffic to a under_maintenance.htm

Hi,

I would like to know how to setup an IRule which will redirect all the HTTP/HTTPS traffic to URL(say under_maintenance.htm) when we make websites down for maintenance activities.

Also, in case of case of NLB with 2 NODES. where both nodes are down then how to redirect the traffic to a custom page.

There are a few additional options to consider:

  1. Fallback Host: Inside the HTTP profile is an option called Fallback Host. This option, when defined, will send a 302 redirect to the specified address if all pool members are down. No iRules needed.

  2. active_members check: a simple active_members check of the pool and then whatever you need to happen if all members are down:

    when CLIENT_ACCEPTED {
        set default_pool [LB::server pool]
    }   
    when HTTP_REQUEST {
        if { [active_members $default_pool] < 1 } {
             send a redirect or output HTML content here
        }
    }
    
  3. Time-based outage: based on the following post:

    DevCentral

    when RULE_INIT {
        set static::START_OFF_TIME "Saturday 09:00 AM"
        set static::END_OFF_TIME "Saturday 11:00 AM"
    }
    when HTTP_REQUEST {
        set start_off_time [clock scan $static::START_OFF_TIME]
        set end_off_time [clock scan $static::END_OFF_TIME]
        set now [clock seconds]
    
        if { ( [expr $now > $start_off_time] ) and ( [expr $now < $end_off_time] ) } {
            HTTP::respond 200 content "Maintenance ModeMaintenance mode..."
        }
    }
    

Since the Fallback Host generates a 302 (possibly followed by a 200) this could do bad things to SEO. A 503 (Service Unavailable) would be preferable in many cases.