I’m pretty new to iRules and trying to modify an existing code to do the following : 1) if pool is down, show page down 2) if pool is on high request, show high load page.. 3) both pages will have same images loaded in the ifiles
below is the code with 1) & 3) only and im not sure how to modify to include 2. any pointers will be appreciated.
when HTTP_REQUEST { if { [active_members pool_abc] < 1 } { log local0. “All pool members down: Redirecting to outage page.” if { [HTTP::uri] eq “/assets/images/Company-Logo.png” } { HTTP::respond 200 content [ifile get companylogo.png] “Content-Type” “image/png” } else { HTTP::respond 200 content [ifile get maintenance.html]
You need to do use something to define what heavy load is.
There’s a good bit of code by Hoolio that sets a maximum number of connections which could be used as your heavy load threshold. You could modify this to suit your requirments.
You could serve content from your iFiles instead of the static content in the example.
just noticed the log.. not sure what it meant..(with my initial code)
TCL error: /Common/ - Operation not supported. Multiple redirect/respond invocations not allowed invoked from within “HTTP::respond 200 content [ifile get companylogo.png] “Content-Type” “image/png””
the problem was it is not possible to have multiple response for one request (i.e. request matches two HTTP::respond commands). return helps because it would exit from irule execution after matching HTTP::respond.