IBM Support

Setting the X-Forwarded-For header using IBM HTTP Server

Technote (FAQ)


Question

How do I configure IBM HTTP Server to set a header called "X-Forwarded-For" equal to the IP address of the client?

Cause

The X-Forwarded-For header is not required by IBM HTTP Server (IHS) or by IBM WebSphere Application Server (WAS). But it may be required by software from other vendors.

Answer

For more information about the X-Forwarded-For header, see the definition on Wikipedia here: http://en.wikipedia.org/wiki/X-Forwarded-For

NOTE: No configuration is necessary when IBM HTTP Server is configured as a reverse proxy, as this header is added automatically by mod_proxy_http.

To configure IBM HTTP Server to set the X-Forwarded-For header to the client IP address, in a non-proxy request, you need to enable the mod_rewrite and mod_headers modules, and then add the following lines in the IBM HTTP Server config (httpd.conf):


RewriteEngine on
RewriteRule ^(.*) - [E=CLIENT_IP:%{REMOTE_ADDR},L]
RequestHeader set x-forwarded-for %{CLIENT_IP}e


In WebSphere Application Server, J2EE APIs that access the client IP address are not affected by the X-Forwarded-For header. The IBM web server Plug-in sends the client IP address to WebSphere Application Server in proprietary ($WS) headers. To learn more about HTTP headers, including the IBM $WS headers, please see the following webcast replay:
http://www.ibm.com/support/docview.wss?uid=swg27014842

Cross reference information
Segment Product Component Platform Version Edition
Application Servers WebSphere Application Server IBM HTTP Server AIX, HP-UX, Linux, Solaris, Windows 7.0, 6.1, 6.0.2

Document information

More support for: IBM HTTP Server

Software version: 7.0, 8.0, 8.5

Operating system(s): AIX, HP-UX, Linux, Solaris, Windows

Reference #: 1445012

Modified date: 30 August 2010