Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is request.env['REMOTE_ADDR'] returning two IPs?

Tags:

When I visit my Rails 2.2 app on my remote server I receive the following value as my REMOTE_ADDR.

request.env['REMOTE_ADDR']: "75.184.124.93, 10.194.95.79"

What has me stumped is why there are two IPs. A quick check of my currently leased public IP confirms that my IP is 75.184.124.93.

So where is 10.194.95.79 coming from?

Is there something about how remote addresses are collected and reported in the HTTP headers spec that I'm missing? Is this expected, normal behavior?

like image 558
Jared Brown Avatar asked Mar 11 '10 03:03

Jared Brown


1 Answers

It's definitely because of a reverse proxy.

Reverse proxies (I use BigIPs and Apache mod_proxy mode often) usually append all the intervening IPs to the list so you can pick out the right ones in your code.

For example, you might want to find the public one to log to your webstats application, so there it is right in the REMOTE_ADDR. But you also have the internal IP(s) so you know which loadbalancer it came from, which internal server its on for some kind of internal network tracking, etc

like image 97
John Paul Ashenfelter Avatar answered Oct 04 '22 18:10

John Paul Ashenfelter