Red_19
Apr 08, 2019Nimbostratus
iRule to retrieve the first IP from an HTTP header
Requirement: client traffic will have a header named "Client_IP_XFF" which will have more than 1 IP. They want the LTM to retrieve the first IP from this header and insert it into X-Forwarded-For header. VIP will also get client traffic that will have standard X-forwarded-for folder.
The irule I applied on the VIP is as below, but this isn't going to get the first IP from the folder. Any suggestions on how this can be modified ?
create ltm rule XFF_ClientIP when HTTP_REQUEST { if {[HTTP::header exists "Client_IP_XFF"]}{ HTTP::header remove X-Forwarded-For HTTP::header insert X-Forwarded-For [HTTP::header value "X-Client-IP"] } else {
HTTP::header remove X-Forwarded-For HTTP::header insert X-Forwarded-For [getfield [IP::client_addr] % 1] } }
example of X-Client-IP data : 10.11.20.19,127.0.0.1 irule should get them 10.11.20.19 IP.