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
Cumulonimbus
You can try something like that:
when RULE_INIT {
array set static::timerange {
1 {"05:30" "13:00"}
2 {"05:30" "13:00"}
3 {"05:30" "13:00"}
4 {"05:30" "13:00"}
5 {"00:00" "00:00"}
6 {"00:00" "00:00"}
7 {"05:30" "13:00"}
}
}
when HTTP_REQUEST {
if { ([string tolower [HTTP::uri]] contains "/contractor/") } {
set now [clock seconds]
set current_day [clock format $now -format {%u}]
lassign $static::timerange($current_day) start end
if {($now >= [clock scan $start]) && ($now < [clock scan $end])} {
set denied 0
} else {set denied 1}
} else {set denied 0}
if { $denied } {
HTTP::respond 200 content "Not Authorised! Contact AdministratorNot Authorised! Contact Administrator..."
} else {pool POOL_443}
}
you can also use day name instead of number in array...
Ashu_Aggarwal
Oct 18, 2020Cirrus
: Hi, I have a similar requirement & when trying the above i-rule it looks like it blocks the access but it doesn't pick/sync with the system clock. It just keep denying the requests. Can you please suggest?
Rgds/Ashu
- Stan_PIRON_F5Oct 19, 2020Employee
I don't remember if this code used GMT or local timezone..
The comment I wrote above says lassign is not supported... try the code above.
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