14-Feb-2021 22:51
hi
i need to set the x-forwrd-for ip as perflow.client.ip.address value.
i have enabled accept x-forward for in http profile, but still perflow.client.ip.address get the actual client ip.
how can i achieve this.
15-Feb-2021
07:19
- last edited on
04-Jun-2023
21:03
by
JimmyPackets
Hi,
how about using an Access Policy Agent event for per-request policy in an iRule. Here is an example iRule.
when HTTP_REQUEST {
if { [HTTP::header values "X-Forwarded-For"] ne "" } {
log local0. "X-Forwarded-For: [HTTP::header X-Forwarded-For]"
set clientip [getfield [HTTP::header X-Forwarded-For] "," 1]
}
}
when ACCESS_PER_REQUEST_AGENT_EVENT {
if { [ACCESS::perflow get perflow.irule_agent_id] eq "EVENT_NAME" } {
ACCESS::perflow set perflow.custom $clientip
}
}
This will check if the header is set and if it exists it will write the IP to a variable and also will log it to /var/log/ltm.
Then, once matching an Access Policy Agent event for per-request policies (in this example the event is called EVENT_NAME) it will reuse this variable and write to IP the to perflow.custom variable. This perflow variable you could use as a gating category.
15-Feb-2021
19:53
- last edited on
24-Mar-2022
01:23
by
li-migration
thanks it working as excepted.