27-Jan-2021 04:31
Hello,
Hopefully someone is able to help me.. We have a Big-IP hosted in AWS and running 15.1.0.4. We have a maintence page that needs to display when the pool members are down (which i have working) but also on Tuesdays 0200-1400. I have tried several different pages but am still struggling to get this working. Any help would be greatly appreciated.
27-Jan-2021 07:56
Hi,
You could use this:
when RULE_INIT {
array set static::timerange {
Sunday {}
Monday {}
Tuesday {"02:00" "14:00"}
Wednesday {}
Thursday {}
Friday {}
Saturday {}
}
}
when HTTP_REQUEST {
if { ([string tolower [HTTP::uri]] contains "/contractor/") } {
set now [clock seconds]
set current_day [clock format $now -format {%A}]
set start [lindex $static::timerange($current_day) 0]
set end [lindex $static::timerange($current_day) 1]
if {($start ne "") && ($end ne "") && ($now >= [clock scan $start]) && ($now < [clock scan $end])} {
set denied 0
} else {set denied 1}
unset start end
} else {set denied 0}
if { $denied } {
HTTP::respond 200 content "Not Authorised! Contact AdministratorNot Authorised! Contact Administrator..."
} else {pool POOL_443}
unset denied
}
Cheers,
Kees
27-Jan-2021 12:18
Would i have to have this as a seperate irule than the one i have for when pool members are down? Sorry i am not the best with iRules.
28-Jan-2021 00:24
No, it can be the same irule.
when RULE_INIT {
array set static::timerange {
Sunday {}
Monday {}
Tuesday {"02:00" "14:00"}
Wednesday {}
Thursday {}
Friday {}
Saturday {}
}
}
when HTTP_REQUEST {
if { ([string tolower [HTTP::uri]] contains "/contractor/") } {
set now [clock seconds]
set current_day [clock format $now -format {%A}]
set start [lindex $static::timerange($current_day) 0]
set end [lindex $static::timerange($current_day) 1]
if {($start ne "") && ($end ne "") && ($now >= [clock scan $start]) && ($now < [clock scan $end])} {
set denied 0
} else {set denied 1}
unset start end
} else {set denied 0}
if { $denied } {
HTTP::respond 200 content "Not Authorised! Contact AdministratorNot Authorised! Contact Administrator..."
} elseif { [active_members [LB::server pool]] == 0 } {
HTTP::respond 200 content "<content>"
unset denied
} else {pool POOL_443}
unset denied
}
Cheers,
Kees