Forum Discussion

someguy's avatar
someguy
Icon for Nimbostratus rankNimbostratus
Mar 06, 2014

How can I return content directly from an irule and skip LB/server interaction?

I'm trying to return a pre-defined html page directly from an F5 without hitting backend servers (DC health-check). I have come up with the below irule, but it appears to work about half of the time, the other half it hits the pool and generates a 404. Seems like this should be simple, what am I doing wrong?

when HTTP_REQUEST {
    if {[HTTP::uri] equals "/ping.html" }
    {
        set object [class lookup "ping" "ping_objects"]
        HTTP::respond 200 content $object noserver Cache-Control No-Cache Pragma No-Cache
        event disable all
        return
    }
}

2 Replies

  • Hi mate! Event disable all would probably lead to using the default pool for all the subsequent requests in the same connection. Try removing it and it should work.

     

    /Patrik

     

  • Hi! The connection reset is probably due to other rules executing pool selections or redirects.

    when HTTP_REQUEST {
        if {[HTTP::uri] equals "/ping.html" }
        {
            set object [class lookup "ping" "ping_objects"]
            HTTP::respond 200 content $object noserver Cache-Control No-Cache Pragma No-Cache
            set dchc 1
    
        }
    }
    

    Then start all the following rules with the following if statement:

    if { [info exists blocked] && $blocked == 1 } {
        Doing nothing here because of DCHC variable being set
    } else {
        Put the old iRule content here.
    }
    

    /Patrik