Niranjan,

You’re probably looking for the functionality of  mod_emoteip 
(https://httpd.apache.org/docs/2.4/mod/mod_remoteip.html).

I followed the guide at 
https://www.globo.tech/learning-center/x-forwarded-for-ip-apache-web-server/ to 
set it up.

What wasn’t clear to me is that you need to add the mod_remoteip module on the 
backend server.
If you’re using mod_proxy or similar the X-Forwarded-For header is added 
automatically.
The mod_remoteip replaces the client IP in the headers with the value of the 
(first) IP in X-Forwarded-For when it matches one of the trusted IP’s (set in 
RemoteIPInternalProxy or RemoteIPTrustedProxy).

HTH

Bram

From: Niranjan Rao <nhr...@gmail.com> 
Sent: Tuesday, 5 January 2021 19:50
To: users@httpd.apache.org
Subject: [users@httpd] Remote ip address as a header

Greetings,

Server version: Apache/2.4.29 (Ubuntu)

I am trying to forward remote ip address to my backend server. Visit to backend 
server involves multiple hops between various load balancers until ip address 
is used. We tried following in the config file to set the X-REQUEST-IP address 
header to carry it forward from the entry point, but not seeing the header set.

Header set X-REQUEST-IP %{REMOTE_ADDR}s

Is this the right way to do it?

Regards,

Niranjan

Reply via email to