Forum Discussion

Domai's avatar
Domai
Icon for Altostratus rankAltostratus
Apr 12, 2016

iRule help

Hello Guys, Quick question and need help with the iRule below. The goal is to setup an apology page when the all the pool members are down. so using the iRule below (Thank you nitass)

 

========================================================================

 

when HTTP_REQUEST { if {[active_members [LB::server pool]] < 1} {

 

switch [HTTP::uri] {

 

"/" { HTTP::respond 200 content [ifile get "apology"] }

 

"/apology_pic" { HTTP::respond 200 content [ifile get "apology_pic"] }

 

}

 

}

 

}

 

========================================================================

 

So when the user goes to and the pool members down the page is displayed fine. But lets say if the user is a smartypants and knows his vir dir and types in -

 

www.site.com/getstatus.aspx then the apology page does not come up. Looking at the above rule I assumed that switch [HTTP::uri] will handel this...Am I wrong? How do I fix the above iRule?

 

  • Hi

     

    You could either send your clients a redirect back to /apology (or some other) or you just need to change your logic slightly so that you are not looking for an absolute path. Something like this might work

     

    when HTTP_REQUEST { 
    
    if {[active_members [LB::server pool]] < 1} { 
        if { [HTTP::uri] eq "/apology_pic"} {
            HTTP::respond 200 content [ifile get "apology_pic"] }
        else {
    
     HTTP::respond 200 content [ifile get "apology"] }
    
    }
    }

    So with this code you are checking for pool availability first, if the pool is down and the call is for /apology_pic then the iRule will serve the iFile, otherwise the holding page iFile gets served. This way the uri doesn't change in the browser and so if someone refreshes and your pool becomes available again then they should be able to carry on browsing

     

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    Since

    HTTP::uri
    includes the query string it would be better to use
    HTTP::path
    to avoid problems if the request includes a query string (or parameter).