For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

cjbarr1234's avatar
cjbarr1234
Icon for Altostratus rankAltostratus
May 31, 2016

iRule Remove Pre-Existing X-Forward-For

Hello,

 

We have a few clients that are injecting X-Forward-for into the client request. The LTM I am managing also Adds on X-Forward-For via source address, so it is duplicating the source address in the request.

 

I'd like to remove the request of any x-forward-for header prior to it hitting the LTM, and then add on the header once it reaches the LTM.

 

Can someone assist me in writing an iRule to accomplish this?

 

Steps would be like...

 

  1. Remove Header X-Forward-for
  2. Add new header X-Forward-for with source_addr

This would then clean any duplicate WAN address showing in the logs.

 

2 Replies

  • Hi,

    You can use the following irule to do that :

    when HTTP_REQUEST {
        HTTP::header remove "X-Forwarded-For"
        HTTP::header replace "X-Forwarded-For" [IP::client_addr]
    }
    
  • You should be able to use this iRule:

    when HTTP_REQUEST {
         The header must first be removed so that a remote user is not able to spoof this value.
        HTTP::header remove X-Forwarded-For
    }
    

    At my site however, I have stopped using X-Forwarded-For and made up my own HTTP Header with this information like X-Custom-ClientIP, this prevents any intermediaries from messing with X-Forwarded-For and losing or changing information.