Forum Discussion

aghazi's avatar
aghazi
Icon for Nimbostratus rankNimbostratus
Jun 21, 2017

iRule F5 logging for Maintenance page redirects

I need to edit 3 iRules to add logging to match Apache for these attributes.

 

Example Format:X-Forwarded-For; EventTime; Request; HTTP Status Code; Referer; User-Agent; Request Time; Host

 

Would someone help me?

 

when HTTP_REQUEST {
    if { 
        ([active_members [LB::server pool]] < 1)
    } then {
        log local0. "Client on Maintenance Page: [IP::client_addr]"
        HTTP::respond 200 content [ifile get portal_maintenance.html]
    }
}
  • aghazi's avatar
    aghazi
    Icon for Nimbostratus rankNimbostratus
    To clarify
    X-Forward for the IP where they're coming from and going to
    EventTime for the time of the event
    Request for the GET file GIF etc that they're requesting
    HTTPStatuscode self explanatory
    Referer is the previous URL link
    User Agent has the browser OS
    Request Time for the duration of the request.
    Host is the main URL
    
  • P_K's avatar
    P_K
    Icon for Altostratus rankAltostratus

    Anthony-

     

    Below iRule will log everything except your event times/durations.

     

    when HTTP_REQUEST {

     

    set LogString "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]"

     

    log local0. "============================================="

     

    log local0. "$LogString (request)"

     

    foreach aHeader [HTTP::header names] {

     

    log local0. "$aHeader: [HTTP::header value $aHeader]"

     

    }

     

    log local0. "============================================="

     

    }

     

    when HTTP_RESPONSE {

     

    log local0. "HTTP Status Code: [HTTP::status]"

     

    }

     

    Hope this helps!