APACHE CONFIGURATION FILE: /etc/httpd/conf.d/httpd.conf
<IfModule remoteip_module>
RequestHeader edit X-Forwarded-For ([0-9]+(?:\.[0-9]+){3})(:[0-9]+)? $1 early
# valid for ALB, ELB, AppGateway or Load Balancer + CloudFront
RemoteIPHeader X-Forwarded-For
# valid for ALB, ELB, AppGateway or Load Balancer + Akamai
RemoteIPHeader True-Client-IP
</IfModule>
The above change will make sure the user’s IP address is added to the request header. The name of the header is X-Forwarded-For.
Also, the header will have 2 IP addresses ( comma separated ). We have to make sure we read the first IP address from the CSV string.