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

**URL:** <https://community.a10networks.com/t/replace-clear-x-forwarded-4-or-insert-if-not-existent/354>\
**Category:** aFleX\
**Created:** [November 18, 2015, 5:36pm UTC](https://community.a10networks.com/t/replace-clear-x-forwarded-4-or-insert-if-not-existent/354 "2015-11-18T17:36:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rportela](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rportela](https://community.a10networks.com/u/rportela)\
**Post date:** [November 18, 2015, 5:36pm UTC](https://community.a10networks.com/t/replace-clear-x-forwarded-4-or-insert-if-not-existent/354/1 "2015-11-18T17:36:45Z")

</div>

Hello,

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

```auto
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

---

<div class="post-metadata">

**Author:** ![diederik](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diederik](https://community.a10networks.com/u/diederik)\
**Post date:** [November 18, 2015, 5:56pm UTC](https://community.a10networks.com/t/replace-clear-x-forwarded-4-or-insert-if-not-existent/354/2 "2015-11-18T17:56:12Z")

</div>

Hello, You can do this when using:

```auto

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:

```auto

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

```

---

<div class="post-metadata">

**Author:** ![rportela](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rportela](https://community.a10networks.com/u/rportela)\
**Post date:** [November 18, 2015, 7:16pm UTC](https://community.a10networks.com/t/replace-clear-x-forwarded-4-or-insert-if-not-existent/354/3 "2015-11-18T19:16:58Z")

</div>

Great. Working !!!

Thank you…

---

<div class="post-metadata">

**Author:** ![diederik](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diederik](https://community.a10networks.com/u/diederik)\
**Post date:** [November 22, 2015, 4:19am UTC](https://community.a10networks.com/t/replace-clear-x-forwarded-4-or-insert-if-not-existent/354/4 "2015-11-22T04:19:37Z")

</div>

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.
