Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

Add a custom "X-forwarded-for" header

Hey Everyone,

I currently have my F5 sitting in front of an older load balancer. My organization needs to encrypt the traffic between the F5 and the webserver. Because of this, the older load balancer can no longer insert a "x-forwarded-for" value into the header because the traffic is encrypted.

So i was hoping to add an irule that replaces or inserts a "x-forwarded-for" value of 10.102.2.53. I was looking at this irule:

when HTTP_REQUEST {
    HTTP::header remove "X-Forwarded-For"
    HTTP::header replace "X-Forwarded-For" [IP::client_addr]
}

But i need the IP::client_addr to be 10.102.2.53. Any little bit of help would be appreciated. Thanks everyone!

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

You can use this line in iRule:

HTTP::header replace "X-Forwarded-For" "10.102.2.53"

or you can erase/insert this header in http profile:

Request Header Erase

Request Header Insert

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

This is the code I ended up going with! Thanks to the community for all the help like always!

when HTTP_REQUEST {
    HTTP::header remove "X-Forwarded-For"
#    HTTP::header replace "X-Forwarded-For" [IP::client_addr]
     HTTP::header replace "X-Forwarded-For" 10.102.22.53
}
0