Product Documentation

Example 2: Adding a Local Client-IP Header

Aug 30, 2013

Example Inc. wants to add a local Client-IP HTTP header to incoming requests. This example contains two slightly different versions of the same basic task.

To add a local Client-IP header by using the command line interface

At the command prompt, type the following commands in the order shown:

add rewrite action act_ins_client insert_http_header NS-Client 'CLIENT.IP.SRC' 
add rewrite policy pol_ins_client 'HTTP.REQ.HEADER("x-forwarded-for").EXISTS || HTTP.REQ.HEADER("client-ip").EXISTS' act_ins_client 
bind rewrite global pol_ins_client 300 END

To add a local Client-IP header by using the configuration utility

In the Create Rewrite Action dialog box, create a rewrite action with the following description.

Name Type Argument(s)
act_ins_client insert_http_header NS-Client 'CLIENT.IP.SRC'

In the Create Rewrite Policy dialog box, create a rewrite policy with the following description.

Name Expression Action
pol_ins_client 'HTTP.REQ.HEADER("x-forwarded-for").EXISTS || HTTP.REQ.HEADER("client-ip").EXISTS' act_ins_client

Bind both policies to global, assigning the priorities and goto expression values shown below.

Name Priority Goto Expression
pol_check_xfor 100 200
pol_check_xfor 200 300

A local Client-IP HTTP header is now added to incoming requests. You can also modify the configuration above to append all IPs from X-Forwarded-For headers to the new Client-IP header, as shown below.