Forum Discussion
Kai_Wilke
Aug 02, 2016MVP
Hi Jerm,
you may use the iRule below to copy the
"True-Client-IP"
header information (if present) into an additional "X-Forwarded-For"
header. If the "True-Client-IP"
header is not present, the iRule would simply store the client IP address of the underlying TCP session as "X-Forwarded-For"
header value...
when HTTP_REQUEST {
Removing existing "X-Forwarded-For" headers to avoid duplications.
HTTP::header remove "X-Forwarded-For"
Check if "True-Client-IP" is present
if { [set true_client_ip [HTTP::header value "True-Client-IP"]] ne "" } then {
"True-Client-IP" header is present. Copying "True-Client-IP" value to "X-Forwarded-For"
HTTP::header insert "X-Forwarded-For" $true_client_ip
} else {
"True-Client-IP" header is not present. Setting the real client IP as "X-Forwarded-For"
HTTP::header insert "X-Forwarded-For" [getfield [IP::client_addr] "%" 1]
}
}
Cheers, Kai