Forum Discussion
F5 iRule for Header insert
it seems you want to replace the header value with something else? What do you want to accomplish exactly?
You can try this.
if { [HTTP::header exists x-id] } {
set VALUE [HTTP::header "XXX#YYYY"]
#log command to determine if VALUE is set correctly
log local0. "x-idlog var VALUE=$VALUE"
# header x-d allready exists -> remove it first.
HTTP::header remove x-id
# add header x-id with variable VALUE
HTTP::header insert x-id $VALUE
}
The problem might be the var VALUE is not set correctly, and is thus empty.
Hello Cypher,
our header x-id is empty per default and the WAF doesen't like that and blocks our request, so I want to set a value
for the header x-id, now I set your iRule active and the header is still empty, in the system log I got just the messages
HTTP | :header insert x-id $VALUE |
syslog-ng | log local0. \"x-idlog var VALUE=$VALUE\" |
- CypherFeb 12, 2024Cirrus
i would troubleshoot 'bottom-up' and use lowercase for variables (not sure if that has an impact, but it is a good practice).
i don't know what XXX#YYYY is, but it needs to exists as a header, or whatever you use instead of XXX#YYYY. so lets see if it exists first in the logs.
when HTTP_REQUEST {
foreach header_name [HTTP::header names] {
log local0. "$header_name"
}
if { [HTTP::header exists x-id] } {
set value [HTTP::header "XXX#YYYY"]
#log command to determine if VALUE is set correctly
log local0. "x-idlog var value=${value}"
# header x-id allready exists -> remove it first.
HTTP::header remove x-id
# add header x-id with variable value
HTTP::header insert x-id $value
}
}check system > logs > local traffic for errors and logs.
Recent Discussions
Related Content
* 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