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.
- Susheel_308346Oct 27, 2017Nimbostratus
Vernon, Thank you for your response. When application request us to take them offline to avoid impacting response time for other apps in our shared environment. We force offline their application which will show 404 to end users, can we put an iRule to show end users a maintenance page instead of 404 only specific to that pool.
- VernonWellsOct 27, 2017Employee
Yes. The solution above does that. The snippet:
HTTP::respond 200 contents { ... }
responds with a 200 (OK) and with the contents between the braces (presumably the HTML of your maintenance page). Once again, using an iFile to store your maintenance page usually makes more sense.
- Susheel_308346Oct 27, 2017Nimbostratus
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"] } }