Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

It appears my Amazon Elastic Load Balancer is allocating traffic to EC2's, but without their IP addresses?

Is this usual behaviour? It's incredibly annoying. I.e. ELB CName is on my domain name DNS, I hit the domain and access log has the IP address of the ELB, not the visitor.

share|improve this question
    
Ok, again - found it.... for those searching on this... resullus.org/capturing-client-ip-address-in-apache-when-us –  waxical Oct 25 '11 at 17:40
add comment

2 Answers

If you're running ELB in HTTP mode, it adds some HTTP headers to the request sent to the EC2 instances, amongst which is the X-Forwarded-For header which will contain the IP address of the client.

X-Forwarded-For: 203.0.113.7

Note that this header can potentially contain more than one IP if other load balancers or proxies handled the request. In this case you want to extract the first IP listed.

X-Forwarded-For: 203.0.113.7, 10.12.33.44, 10.73.23.88
share|improve this answer
add comment

Since the link in your comment is broken, here's how to log visitors' IP addresses:

In httpd.conf, create a new log format:

LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined-elb

Then to use it:

CustomLog logs/access_log combined-elb

It's that simple.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.