(Originally posted July 9, 2007)
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:
In TrafficScript, you would use the following:
http.setHeader("X-Forwarded-For", request.getRemoteIP());
*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 );
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,