Forum Discussion

SanjayP's avatar
SanjayP
Icon for Nacreous rankNacreous
Feb 17, 2014

iRule for logging x-forwarded-for header

Getting client request with x-forwarded-for header value. How to log these using irule and using data group for specific client ips

 

1 Reply

  • F5 Rocks,

    Your request isn't 100% clear but here is something to get started...

    Logging

    To log out the X-Forwarded-For header

    log local0. "X-Forwarded-For: [HTTP::header X-Forwarded-For]"

    Data Group of IPs

    Create a Data Group of type Address (for this example called client_ip_class) and add the IP addresses of interest. Use something like the following to check if an address exists in the Data Group

    if { [class match [IP::client_addr] equals client_ip_class] } {
        The client IP address is in the class file client_ip_class
         Do something here...
    }
    

    Hope this helps.