Replace/Clear X-Forwarded-4 or insert if not existent

Hello,

We’re using the following script to insert an XFF header.

when HTTP\_REQUEST \{
HTTP::header insert "X-Forwarded-For" [IP::client\_addr]
\}

How do I change it to SET (not insert) a single header ?
I mean if there is already an XXF, we want to clear it....before inserting our own.

Thank you

Hello, You can do this when using:


HTTP::header [value] <name> <string>

Sets the value of the named header. If the header is present, the command replaces the header; otherwise, the com- mand adds the header. You can omit the argument if the header name does not collide with any other val- ues. And make it:


when HTTP_REQUEST {
HTTP::header “X-Forwarded-For” [IP::client_addr]
}

Great. Working !!!

Thank you…

On addition.

If there is a chance there are multiple instances of the same header, the HTTP:header command will only overwrite one.

You need to use “HTTP:header remove” first to remove all instances of that header.
Before you add a new one or insert one.