XFF Universal Persistence iRule
Problem this snippet solves: Simple iRule to read the XFF header on an incoming HTTP Request and use a Universal Persistence ID.
Orginal iRule found to have an issue with multiple IP addresses in th...
Updated Jun 06, 2023
Version 2.0Andy_McGrath
Cumulonimbus
Joined November 14, 2005
Andy_McGrath
Cumulonimbus
Jul 25, 2016Yann, You are correct for most headers where multiple headers exist with the same name however the XFF header gets appended, i.e. Format is;
X-Forwarded-For: client, proxy1, proxy2
So there should only ever be a single X-Forwarded-For header within a HTTP request with the first IP address being closest to the original. I could do the following:
[getfield [HTTP::header X-Forwarded-For] "," 1]
However I test a lot of code directly in TCL so the getfield commend is not valid but this is just down to personal preference.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)