Forum Discussion

superd_88943's avatar
superd_88943
Icon for Nimbostratus rankNimbostratus
Sep 23, 2013

User agent query - iRule

Hi, Im wondering is it possible to setup an iRule which will just log the IP address and also the exact type/version of browser that hits my VIP? And if so, some direction would be amazing.. cheers guys :)

 

v11

 

7 Replies

  • It is, try this;

    when SERVER_CONNECTED {
    log local0. "Client IP: [IP::client_addr], Client User Agent: [HTTP::header value User-Agent]" }
    

    May not work or may log continuously if OneConnect is enabled and/or with some persistence methods.

  • when HTTP_REQUEST { log local0. "SRC IP: [IP::remote_addr]" log local0. "User-Agent: [string tolower [HTTP::header User-Agent]]" }

     

    • What_Lies_Bene1's avatar
      What_Lies_Bene1
      Icon for Cirrostratus rankCirrostratus
      Hey JPV, just note that this will generate a log entry for every request within a single session whereas using the CLIENT_CONNECTED event generates just one.
  • you are correct.

     

    However, I didn't think you can get user-agent out of a CLIENT_CONNECTED event.

     

    thx

     

    • What_Lies_Bene1's avatar
      What_Lies_Bene1
      Icon for Cirrostratus rankCirrostratus
      Doh! Indeed. That being the case I'd suggest SERVER_CONNECTED which could occur more than once but not on every request.
  • hi guys.. thanks a million for responses..

     

    one question.. can you advise why i wouldnt be able to extract a user-agent from a CLIENT_CONNECTED, but can for a SERVER_CONNECT?

     

  • Sure, CLIENT_CONNECT occurs before any HTTP is passed (only the three way handshake has occured). With SERVER_CONNECT again only the three way handshake has occurred, server side but client side the HTTP request has been received and parsed.

     

    In other words, all the required client side events have occured before the first server side one, SERVER_CONNECT.