Forum Discussion
____177053
Cirrus
Jul 21, 2017How to remove the last IP from X-Forwarded-For
If there's multiple IP address in X-Forwarded-For,how to remove the last IP address?
- cjunior
Nacreous
Hello,
Given the XFF in general list format, I would do so:Incoming: X-Forwarded-For: 10.10.10.10, 10.10.10.20, 10.10.10.30 Outgoing: X-Forwarded-For: 10.10.10.10, 10.10.10.20
Sintax:
when HTTP_REQUEST { if { [HTTP::header exists X-Forwarded-For] && [HTTP::header X-Forwarded-For] contains "," } { set xff [HTTP::header X-Forwarded-For] HTTP::header replace X-Forwarded-For [string range $xff 0 [expr {[string last , $xff]-1}]] } }
Regards.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects