Forum Discussion
JRahm
Jan 11, 2024Admin
Hi Nandhi, I am not able to get the profile suggestions by Paulius or zamroni777 working in my local lab (happy to be told what I'm doing wrong!) but I am able to a) remove any existing X-Forwarded-For that arrives and b) insert new based on the requests client IP address both via iRule and local traffic policy. I find the traffic policy overly complicated as it requires Tcl anyway, so personally I'd use the iRule, but both solutions work.
iRule
when HTTP_REQUEST {
if { [HTTP::header exists "X-Forwarded-For"] } {
HTTP::header remove "X-Forwarded-For"
}
HTTP::header insert "X-Custom-XFF" [IP::client_addr]
}
Policy
ltm policy insert_custom_xff {
last-modified 2024-01-10:15:50:09
requires { http }
rules {
custom_xff {
actions {
0 {
http-header
insert
name X-Custom-XFF
value tcl:[IP::client_addr]
}
}
ordinal 1
}
remove_std_xff {
actions {
0 {
http-header
remove
name X-Forwarded-For
}
}
}
}
status published
strategy all-match
}