How to get client IP behind an AWS ELB?

Abs picture Abs · Aug 31, 2013 · Viewed 21.5k times · Source

With a webserver (apache or nginx) I am able to find the x-forwarded-for header and find the client IP rather than the ELB's IP.

Can I do the same thing using IPTables so that I am able to block certain IP addresses?

I can do this at the webserver level. However, I think this is a bit inefficient and I am hoping I can achieve this with IP Tables or something similar?

Answer

Diego Fernández Durán picture Diego Fernández Durán · Sep 3, 2013

Since July 30th ELB supports Proxy Protocol. As stated in the end of this thread in the AWS forum:

Elastic Load Balancing (ELB) now supports Proxy Protocol version 1. This feature allows you to identify the client’s connection information when using TCP load balancing, providing additional insight into visitors to your applications. Having this information can be useful for analyzing traffic logs, gathering connection statistics, troubleshooting, or managing whitelists of IP addresses.

You must enable Proxy Protocol in the ELB.

The developers guide has more information about Proxy Protocol.