Forum Discussion
Erick_Hammersm1
Feb 02, 2007Historic F5 Account
How to replace only second instance of header?
I'm trying to write a rule that will take an HTTP request that contains two "X-Forwarded-For" headers and rename only the second one. Is there any way to accomplish this in v9.1.2? I can get it done with "HTTP::header values", but v9.4 is not an option for these devices right now.
- Danielseyoum
Altostratus
Try the getfield command: - Erick_Hammersm1Historic F5 AccountThanks for the replies. Unfortunately, [HTTP::header] isn't valid syntax. You have to pass it the name of the header you want to process, and it only ever returns the first header with that name (this was resolved in v9.4 with "HTTP::header values", which returns all values for a header). If I was using v9.2, I could use "HTTP::request" to get the whole request and parse out the headers I'm looking for, but I need a solution for v9.1.2.
when HTTP_REQUEST { if { [HTTP::header exists X-Forwarded-For] } { HTTP::header insert Akamai-Peer-IP [IP::remote_addr] } else { HTTP::header insert X-Forwarded-For [IP::remote_addr] } }
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