Forum Discussion

Jon_46029's avatar
Jon_46029
Icon for Nimbostratus rankNimbostratus
May 16, 2012

Redirecting a client when "connection refused" by pool

When all of the pool members are down for a Virtual Server (VS), we're seeing a connection refused error at the browser.

 

 

I'd like to catch that in the F5 LTM with an iRule and direct the browser to a different site hosting a maintenance status message.

 

 

Without an existing HTTP session, though, there's no 404 data and HTTP::* events don't appear to be setup. (HTTP::redirect won't work on SERVER_CLOSED which appears to be the only event I can find that traps the condition).

 

 

Suggestions?

 

Jon

 

 

 

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus
    Jon

     

     

    Is the different site you want to forward users to an external web address? If so would this work?

     

     

    when CLIENT_ACCEPTED {

     

    if { [active_members [LB::server pool]] == 0 } {

     

    HTTP::redirect "http://www.test.com"

     

    }

     

    }

     

     

    You could always use Priority Group Activation so you can add another pool member to the pool that just has an maintenance page on it and set this pool member to only be live if all the other pool members are down. In this case you could always use an old, low spec server as the fallback here.

     

     

    Hope this helps,

     

    N

     

     

  • John_Alam_45640's avatar
    John_Alam_45640
    Historic F5 Account

     

    Here is Nathan's iRule with small modification: (works well for http and https)

     

     

    when HTTP_REQUEST {

     

    if { [active_members [LB::server pool]] == 0 } {

     

    HTTP::redirect "http://www.test.com"

     

    }

     

    }

     

     

    Priority grouping is a good idea too.

     

     

    To answer Jon's question, as to: which event catches the condition of "NO members available", that would be the LB_FAILED event.

     

     

    Check out this link:

     

    https://devcentral.f5.com/weblogs/jason/archive/2009/09/08/irules-insight-http-event-order.aspx

     

     

     

    John

     

  • When all of the pool members are down for a Virtual Server (VS)

    That's what triggers the LB_FAILED event. Something simple like this should work:

    
    when LB_FAILED {
      HTTP::redirect "/maintenance.html"
    }
    
  • The LB_FAILED event seems to be the best option, though I do not have a complete test environment... I don't think the HTTP::redirect flies cause there's no HTTP connection (yet) to redirect.

     

     

    From the wiki: (though the sample code and the text following are in conflict regarding the sequence of the "LB::reselect" and "pool" statements.)

     

     

    when LB_FAILED {
    07  pool my_Pool
    08  LB::reselect
    09  log "Selected server [LB::server] did not respond. Re-selecting node from myPool"
    10}