IBM Support

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

Question & Answer


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


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.


For more information about the X-Forwarded-For header, see the definition on Wikipedia here:

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:

Related Information

[{"Line of Business":{"code":"","label":""},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSEQTJ","label":"IBM HTTP Server"},"ARM Category":[{"code":"a8m0z000000XasuAAC","label":"IHS->IHS.Config->IHS.Headers"}],"ARM Case Number":"TS004798015","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"},{"code":"PF035","label":"z/OS"}],"Version":"All Version(s)"},{"Line of Business":{"code":"LOB15","label":"Integration"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"ARM Category":[{"code":"a8m0z000000XasuAAC","label":"IHS->IHS.Config->IHS.Headers"}],"Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"},{"code":"PF035","label":"z/OS"}],"Version":"All Version(s)"}]

Document Information

Modified date:
13 January 2021