Forum Discussion
Kevin_Nail
Nimbostratus
Jan 15, 2009Multiple XFF headers
We have a situation where it may be possible for one LTM to insert the XFF and load-blance the packets to another LTM with another XFF set.
I would like to have an iRule the checks for the existence of the XFF header and if it exists then do nothing... else add it in. This is waht I have but it doesn't seem to be working correctly, I am still getting 2 XFF headers in the payload.
Any help would be appreciated
when HTTP_REQUEST {
if {
[HTTP::header exists "X-Forwarded-For"]
}
{
Do nothing
}
else
{
HTTP::header insert "X-Forwarded-For" [IP::client_addr]
}
}
- dennypayne
Employee
I would try using "return" to exit from the HTTP_REQUEST event.when HTTP_REQUEST { if {[HTTP::header exists "X-Forwarded-For"]} return } else { HTTP::header insert "X-Forwarded-For" [IP::client_addr] } }
- Deb_Allen_18Historic F5 AccountHTTP::header replace will add replace the specified header if it's already there, or add it if it is not.
- hoolio
Cirrostratus
I assume you've disabled XFF on the HTTP profile on the second set of LTM's?when HTTP_REQUEST { if {[HTTP::header exists "X-Forwarded-For"]}{ Do nothing log local0. "[IP::client_addr]:[TCP::client_port]: Existing XFF: [HTTP::header values "X-Forwarded-For"]" } else { HTTP::header insert "X-Forwarded-For" [IP::client_addr] log local0. "[IP::client_addr]:[TCP::client_port]: Added XFF: [HTTP::header values "X-Forwarded-For"]" } }
- Colin_Walker_12Historic F5 AccountDon't forget that you don't really need a "do nothing" section of the rule at all. You can accomplish the same thing with negative logic.
when HTTP_REQUEST { if { !([HTTP::header exists "X-Forwarded-For"])}{ HTTP::header insert "X-Forwarded-For" [IP::client_addr] log local0. "[IP::client_addr]:[TCP::client_port]: Added XFF: [HTTP::header values "X-Forwarded-For"]" } }
- Kevin_Nail
Nimbostratus
Thanks for all the help... I added the 'return' word and some quotes around the "X-Forwarded-For" value... It works just fine now.
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects