Forum Discussion
jaskel_106221
Nimbostratus
Aug 27, 2007Header insertion (newbie alert)
Hey there,
So, I'm really new to iRules, and I question about a HTTP::header insert
Basically, I am looking to 'replace' the value of a custom(?) header if it exists in the current...
jaskel_106221
Nimbostratus
Aug 27, 2007Ok, ok....this always happens to me. The minute I post a question, I figure out what I was doing wrong. So, this is what I ended up with:
when HTTP_REQUEST {
Check to see if the header already exists
if { [ string tolower HTTP::header] starts_with "client-ip"} {
If it does, remove the current header element
HTTP::header remove "Client-IP"
The insert our own assuring that only one element exists in the
header
HTTP::header insert "Client-IP" [IP::remote_addr]
}
else {
If it doesn't already exist, insert it.
HTTP::header insert "Client-IP" [IP::remote_addr]
}
}
And it appears to work. I get the inserted header. Now I just have to test if it cleans out the header if it finds the Client-IP portion already in the header on the initial request.
Thanks for anyone who looked and was thinking about replying!
-James
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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