开发者

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

开发者 https://www.devze.com 2022-12-22 19:00 出处:网络
When I visit my Rails 2.2 app on my remote server I receive the followin开发者_开发知识库g value as my REMOTE_ADDR.

When I visit my Rails 2.2 app on my remote server I receive the followin开发者_开发知识库g 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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号