Forum Discussion
Shiraz
Apr 28, 2016Altostratus
Irule to block access of VS on specific days
Dears,
I am able to restrict the access to Virtual Server by providing the static time by using the below irule. However, I also want to use this irule to restrict the access on weekends.
when R...
Stanislas_Piro2
May 03, 2016Cumulonimbus
The lassign command does not work in irule.
The following code may solve this issue.
when RULE_INIT {
array set static::timerange {
Sunday {"05:30" "13:00"}
Monday {"05:30" "13:00"}
Tuesday {"05:30" "13:00"}
Wednesday {"05:30" "13:00"}
Thursday {"05:30" "13:00"}
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
}
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects