I'm using Apache/2.4.27
Within the VirtualHost I'm forwarding the remote client IP header from the Loadbalancer with:
RemoteIPHeader X-Forwarded-For
Which is needed by the application served by that Virtualhost.
This is the log format within the main httpd.conf context.
LogFormat "%h (%{X-Forwarded-For}i) %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
When I have the RemoteIPHeader X-Forwarded-For listed within the virtualhost, Apache stops writting the remote-client IP into logs.
When I remove it from the VirtualHost, the remote-client IP starts appearing again within the logs.
Any ideas why the RemoteIPHeader X-Forwarded-For
doesn't play with (%{X-Forwarded-For}i)
from the LogFormat ?
Thanks !
Best Answer
Proxy Layer (Nginx)
Backend Layer (Apache)
Description:
proxy_set_header - directive sets headers that nginx sends to backend; so in this example We sends two variables (to headers):
X-Forwarded-For
andX-Real-IP
X-Forwarded-For - on the proxy side it must be set that this header should be passed to backends and accessible from their layer
X-Real-IP - it does not affect the required variables on the web page but we leave it enabled so that the Apache server places the client's address in the logs (you also need to set the log format itself):
Curl
tls_check.php