Don't mean to resurrect a very old thread but I ran into a similar issue recently and came across a different solution, so I though I would share!
Similarly we are running a number Amazon EC2 machines behind an AWS Elastic Load Balancer. We wanted to use the HttpLimitReqModule in order limit the number of requests for a given session i.e. stop a DOS attack.
Because we were running behind the load balancer the remote address was always that of Amazons load balancer, i.e. something in the range 10.0.0.0/8
As pointed out by Chris above, x-forwarded-for may be a comma separated list of IPs you cannot just use the x-forwarded-for string. You can use the above perl module script to extract the last IP from x-forwarded-for but there is an easier way.
Nginx has another module, HttpRealIpModule, it allows you to extract the remote addr from x-forwarded-for once you provide an IP(s) of your trusted proxy.
In order to work behind Amazons load balancer you set the trusted proxy to that of Amazons internal range
All you have to do is add the following to your nginx conf:
set_real_ip_from 10.0.0.0/8;
real_ip_header X-Forwarded-For;
Now the $remote_addr variable will the set to that of the user and not the load balancer.
Hope this helps anyone else who runs into this problem.