Apache: adding early client IP and local socket IP options to RequestHeader
When using Apache 2.4 behind a load balancer or proxy along with mod_remoteip, it may be handy for underlying scripts or configuration to know which IP address the direct client (balancer/proxy itself) making the request has. Alas, due to mod_remoteip replacing the IP with the real client IP, this may come tricky. Adding this on balancer is also not always possible because the source IP for connection to HTTP server is not known to balancer at the moment of header mangling.
Also, sometimes it may be handy to make underlying scripts/configuration know about the IP HTTP server accepted connection at, i.e. for multihomed servers.
This small and inobtrusive patch adds two % options to RequestHeader value parser along with the existing ones:
%a - this is substituted with the connecting client IP address, and if used in combination with early option, it provides IP before mod_remoteip does its job.
%A - this is substituted with the IP address of local socket accepting the connection, it provides server IP that the connection is landing onto.
RequestHeader set X-Balancer-IP %a early
RequestHeader set X-Local-IP %A early
Tested against Apache 2.4.27 in production, compatible with Apache 2.4.28.
No feedback yet
Form is loading...