vADC Forum

Reply
Occasional Contributor
Posts: 43
Registered: ‎11-26-2012

How do I pass the client's IP address to my servers in an HTTP header?

(Originally posted July 9, 2007)

N/A
Posts: 2
Registered: ‎10-03-2011

Re: How do I pass the client's IP address to my servers in an HTTP header?

Web applications running behind ZXTM often need to know the client's IP address. By default, ZXTM adds the HTTP header X-Cluster-Client-IP to each HTTP request, but some applications expect to find the client's IP address in a different header, such as X-Forwarded-For. You can add the required header using either RuleBuilder™ or TrafficScript™.

From version ZXTM 4.2 onward, RuleBuilder allows you to use two magic strings "%REMOTE_IP%" and "%REMOTE_PORT%" in RuleBuilder actions, which will be replaced with the remote IP and port respectively when the rule is executed.

The following RuleBuilder rule, for example, sets the client IP address in the X-Forwarded-For header:

236iAEEFD5AD0D680836.png

In TrafficScript, you would use the following:


http.setHeader("X-Forwarded-For", request.getRemoteIP());


Frequent Contributor
Posts: 321
Registered: ‎11-29-2012

Re: How do I pass the client's IP address to my servers in an HTTP header?

*Reply from daan.van.der.sanden *

I use a slightly different approach (more compatible with the description on: <a title="http://en.wikipedia.org/wiki/X-Forwarded-For" target="_blank" href="http://en.wikipedia.org/wiki/X-Forwarded-For">http://en.wikipedia.org/wiki/X-Forwarded-For</a>).

In case there are more proxies in place in the path, the following trafficscript takes this into account.

$xff = http.getheader( "X-Forwarded-For" );
if ( $xff != "") {
$xff = $xff . ", " . request.getRemoteIP();
} else {
$xff = request.getRemoteIP();
}
http.setheader( "X-Forwarded-For", $xff );

 

 

New Contributor
Posts: 2
Registered: ‎11-29-2012

Re: How do I pass the client's IP address to my servers in an HTTP header?

Hi Owen,

One of our Customer using STM 9.3 in their IIS 7.5 Enviroment.

Can I use this Script Rule on STM to send Client Source IP to IIS Servers.

Customer want to see the Orginial Client Ip address in the IIS Server Logs

regards,

Join the Community

Get quick and easy access to valuable resource designed to help you manage your Brocade Network.