Hello guys,
I have the follow irules:
when HTTP_REQUEST {
set url [HTTP::uri]
set metodo [HTTP::method]
if {([HTTP::method] eq “PUT”) and ([HTTP::host] contains “xxxx”)} {
HTTP::path “URLpath”
pool xxxxx
}
}
I would that this irule doesn’t work ( so it been stopped ) in a specify time (ex: in the morning from 8 to 9 am). It is possible to set it with some variable?
Thanks for any tips or idea.
Regards,
Antonino.
Lidev
August 21, 2019, 12:40pm
2
Hi Antonino,
yes you can use time based iRules to do this.
Articles
Community CodeShare
Problem this snippet solves: Here’s a simple example of taking action in an iRule based on a time window. We use the clock scan and clock seconds commands to convert a timestamp in a user-friendly format to UTC (time since the Unix epoch of...
Reading time: 1 min 🕑
Likes: 3 ❤
Hi Lidev,
Thanks for your quick reply. I saw that previusly you wrote about the iCall. The best way is your irule example or use iCall?
Thanks,
Regards.
Lidev
September 17, 2019, 6:22am
4
hello Antonio, sorry for the delay. use an iRule will be better
Hi Antonino,
You have also Stanislas Irule that I find very well:
when RULE_INIT {
array set static::timerange {
Sunday {"05:30" "16:00"}
Monday {"05:30" "16:00"}
Tuesday {"05:30" "16:00"}
Wednesday {"05:30" "16:00"}
Thursday {"05:30" "16:00"}
Friday {}
Saturday {}
}
}
when HTTP_REQUEST {
if { ([string tolower [HTTP::uri]] contains "/contractor/") } {
if {!([class match [IP::remote_addr] equals clntip])} {
set denied 1
} else {
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
}
regards