Logging & Load Balancers - Getting the correct IP address
If you've set up a load balancer and have noticed that your Apache logs are showing all traffic coming from your load balancer's IP address instead of the user's, you can fix it by grabbing the X-Forwarded-For header and using that in the log format in httpd.conf:
LogFormat "%{X-Forwarded-For}i %h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
Within your application code you can grab HTTP_X_FORWARDED_FOR from the server environment variables.
ENV["HTTP_X_FORWARDED_FOR"] # Ruby
$_SERVER["HTTP_X_FORWARDED_FOR"] # PHP