Apache: PROXY protocol for Amazon ELB (Elastic Load Balancing)
Publicado por en
If you want to use Apache 2.2 / 2.4 behind a Amazon ELB (Elastic Load Balancing), HAproxy, Stunnel, Stud o anything similar, you will have seen that in the logs appears IP of ELB instead of the remote client, and filter by IP is a double problem.
The module “remoteip” does not solve the problem. Amazon ELB, HAProxy and others support “PROXY protocol”, that helps to fix this issues working behind proxys.
The protocol look similar to:
PROXY TCP4 10.1.2.3 192.168.0.11 56324 443\r\n
GET / HTTP/1.1\r\n
But Apache currently does not support out-of-the-box. So following the philosophy of Do-It-Yourself, here is the source code (beta):
mod_myfixip.c in Github (for Apache 2.4)
mod_myfixip.c in Github (for Apache 2.2)
UPDATE (2015.01.17): Seems that AWS-ELB don’t always send PROXY header in only one packet / TCP-frame (in some cases data is received fragmented, now the module handle this behavior).
ElasticLoadBalancing: Enable Proxy Protocol