Forum Discussion

Annsar_Akhtar's avatar
Annsar_Akhtar
Icon for Nimbostratus rankNimbostratus
Mar 17, 2015

Setting IP:remote_addr using a custom header

Hi All

 

We have a custom app which is hard coded to capture the ip:remote_addr and wondering if it possible to replace this with a custom header via an irule.

 

Currently the app logs the F5 self ip and I know its possible using X-Forwarded-For header enabled in a HTTP profile to capture the client ip but was wondering if their is a way to use the value from a custom header, this would mean the custom app wont have to be rewritten. The custom header is being inserted via our CDN and wondering if something like the below would work:

 

when HTTP_REQUEST { HTTP::header insert True-Client-IP-CDN [IP::client_addr] log local0. "Client IP: [IP::client_addr]" }

 

Thanks

 

1 Reply

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    You can extract the value from the header that's inserted by the CDN and use it to populate your own header:

    when HTTP_REQUEST { 
    
        HTTP::header insert True-Client-IP-CDN [HTTP::header value CDN-HEADER-NAME]
    
        log local0. "Client IP: [IP::client_addr]" 
    
    
    }