Forum Discussion
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...
- Remove Header X-Forward-for
- 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] }- Walter_Kacynski
Cirrostratus
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.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com