Forum Discussion
Yes, this can be achieved using an iRule, but you'll want to be quite clear about the conditions that can trigger this. The very high-level logic is this:
when HTTP_RESPONSE {
if { } {
set condition_started_at [table lookup condition]
if { $condition_started_at eq "" } {
table set condition [clock seconds] indef indef
}
else {
if { [clock seconds] > $condition_started_at } {
HTTP::respond 200 contents {
}
}
}
}
else {
table delete condition
}
}
}
I haven't tested this, since it's just psuedo-code. For the HTTP::respond you may consider using an iFile, as has been suggested in other posts.
You should be aware that both the table calls and the clock calls are fairly costly. There is an alternative form that uses static:: variables and a Tcl Associative Array, but that means each tmm will compute the condition independently. That might be okay for you, and it is considerably cheaper/faster than using table.
Thank you for your response. I'm trying to add if it matches for a specific URI like /abc. I want to display 404. I tried using HTTP::uri but I got a failure that it should be used in HTTP::Request.
when HTTP_RESPONSE { if { ( [HTTP::status] == 404 ) } { log local0. "Maintenance Page Enabled" HTTP::respond 200 content [ifile get "maintenance"] } }