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

 

3 Replies

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus
    Where do you want to log the values? What are the specifics regarding client IP-addresses?
  • The simplest approach might be something like this:

    when HTTP_REQUEST {
        if { [HTTP::header exists X-Forwarded-For] } {
            log local0. "Received XFF from [IP::client_addr]: [HTTP::header X-Forwarded-For]"    
    
            if { [class match [HTTP::header X-Forwarded-For] equals my_ip_dg] } {
                log local0. "Data group source match"
            }
        }
    }