IBM Support

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

Question & Answer


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

[{"Product":{"code":"SSEQTJ","label":"IBM HTTP Server"},"Business Unit":{"code":"BU004","label":"Hybrid Cloud"},"Component":"Not Applicable","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"8.5;8.0;7.0","Edition":""},{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU004","label":"Hybrid Cloud"},"Component":"IBM HTTP Server","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"7.0;6.1;6.0.2","Edition":""}]

Document Information

Modified date:
15 June 2018

UID

swg21445012