Using "X-Forwarded-For" in Apache

This post gone be helpful if your incoming traffic is coming from NATed IP and you want to get the actual IP instead of the NATed one for some reason.

Before few days, I created two web server and one load balancer in Amazon EC2. Load balancer was forwarding traffic to two web servers. That was working fine, but due to nature of Amazon ELB we could not get the actual Source IP from where our site was being accessed.

So by googling, we found that using "X-Forwarded-For" we can get the original source's IP Address and we can utilize it for further use(may be for troubleshooting or for Geocoding or for webalizer to create informative graphs). It was just a 3 line of code, which did a trick. You can use that in apache configuration.

No comments:

Post a Comment