Forum Discussion
bsm1970
Nimbostratus
Sep 09, 2019Restrict access to virtual server during specified time
I'm wondering if there is a way in the F5 to restrict access to a virtual server during certain hours. For instance, if I wanted to only allow access during work hours (say, from 7am to 6pm on weekd...
- Sep 10, 2019
try this:
when RULE_INIT { array set static::timerange { Sunday {"07:00" "18:00"} Monday {"07:00" "18:00"} Tuesday {"07:00" "18:00"} Wednesday {"07:00" "18:00"} Thursday {"07:00" "18:00"} Friday {} Saturday {} } } when HTTP_REQUEST { 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 if { $denied } { HTTP::respond 200 content "<html><head><title>Not Authorised! Contact Administrator</title></head><body>Not Authorised! Contact Administrator...</body></html>" } else {pool POOL_443} unset denied }
Stanislas_Piro2
Cumulonimbus
Sep 10, 2019try this:
when RULE_INIT {
array set static::timerange {
Sunday {"07:00" "18:00"}
Monday {"07:00" "18:00"}
Tuesday {"07:00" "18:00"}
Wednesday {"07:00" "18:00"}
Thursday {"07:00" "18:00"}
Friday {}
Saturday {}
}
}
when HTTP_REQUEST {
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
if { $denied } {
HTTP::respond 200 content "<html><head><title>Not Authorised! Contact Administrator</title></head><body>Not Authorised! Contact Administrator...</body></html>"
} else {pool POOL_443}
unset denied
}bsm1970
Nimbostratus
Sep 10, 2019This seems to work well. Thanks to both of you for the quick replies!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
