Forum Discussion

Brandon_Van_849's avatar
Brandon_Van_849
Icon for Nimbostratus rankNimbostratus
Mar 05, 2012

HTTP_Request and LB::Status

Im trying to use the HTTP_response 200 content from a IF statment made with LB::status. I have gotten the F5 to accept the irule with out error but i am still not getting the result i want. I want the f5 to intercept a request and feed out a custom message that i create based on the web pool being down. That is the rule i config'd however, for some reason all i get when services are down is the typical IE "page cannot be displayed". What is the problem?
  • Posted By Brandon Van on 03/05/2012 08:26 AM

     

    it is worth noting that the portal that user are trying to access are https, just fyi

     

    Hi Brandon,

     

     

    does that mean that you are terminating https on the F5 BIG-IP LTM ? If so, it should not matter. Would you be able to share the virtual server config and the irule with us ?

     

     

     

    Thanks

     

    Christian

     

  • when HTTP_REQUEST {

     

    if { [LB::status pool *pool-name* member xxx.xxx.xxx.xxx *port*] eq "down"} {

     

    HTTP::respond 200 content {

     

    blah, blah, blah

     

     

    }

     

    }

     

    }
  • Hi Brandon,

     

     

    A load balancing selection hasn't been made when the HTTP_REQUEST event is triggered. You could move this logic to the LB_SELECTED event. But really, LTM shouldn't be selecting a pool member that's down anyhow.

     

     

    Overall, what you are trying to do or what issue are you trying to address?

     

     

    And welcome to the forums Christian :)

     

     

    Aaron
  • Hi Brandon,

    here an example:

    when CLIENT_ACCEPTED {
      set def_pool [LB::server pool]
      set lb_fails 0
    }
    
    when LB_FAILED {
        if { $lb_fails < [active_members $def_pool] } {
            LB::mode rr
            LB::reselect pool $def_pool
           } else { 
            HTTP::respond 200 content {
            
             
                Apology Page
             
             
                We are sorry, but the site you are looking for is temporarily out of service
                If you feel you have reached this page in error, please try again.
             
            
            }    
        }
      incr lb_fails
    }
     
  • here is what we are trying to do. when we have to take down the system for maintenance we want to display a message, but we want to use the pool members as the IF statement instead of the http codes. there is only one web pool. and when services are stopped the pool status is red or down. would this work?
  • The following irule will achieve this:

     

     when CLIENT_ACCEPTED {
      set my_pool [LB::server pool]
    }
    
    when LB_FAILED {
    log local0. "[active_members $my_pool]"
        if {  [active_members $my_pool] < 1 } {
            HTTP::respond 200 content {
            Apology Page
                We are sorry, but the site you are looking for is temporarily out of service
                If you feel you have reached this page in error, please try again.
             
            }    
        }
    }
     
    The event CLIENT_ACCEPTED is only needed to get the pool name, and then it checks on LB_FAILED, if really no member is there, then it sends back the maintenance page. Alternatively this will work also if attached to HTTP_REQUEST, but that means the code will run on every request, while LB_FAILED will only run if the systems fails to select a pool member. see also https://devcentral.f5.com/wiki/iRules.lb_failed.ashx