$ _SERVER ['REMOTE_ADDR']让我只托管IP,而不是用户的IP。 为什么?

$ _SERVER ['REMOTE_ADDR']让我只托管IP,而不是用户的IP。 为什么?

问题描述:

Recently I've needed to change my counter code in my blog site. That is why some attackers manipulate counter numbers of my articles, using a program or anything else.

They can increment the counter to 4000 in a day. So I've changed the counter algorithm. Now I'm using a counter based on IP address. But I have a question about this. I know that $_SERVER['REMOTE_ADDR'] gives us the IP address from which the user is viewing the current page.

I taked this explanation from: http://php.net/manual/en/reserved.variables.server.php. But this command didn't give me users' IP addresses. It always gave me just hosting IP address. Why?

Could anyone explain this situation, please? Fortunately, I've found a code snippet from the github, and I can use this new counter. (https://gist.github.com/cballou/2201933)

Why just the $_SERVER['REMOTE_ADDR'] doesn't work?

最近我需要在博客网站上更改我的计数器代码。 这就是为什么一些攻击者使用程序或其他任何东西操纵我的文章的计数器数。 p>

他们可以在一天内将计数器增加到4000。 所以我改变了计数器算法。 现在我正在使用基于IP地址的计数器。 但我对此有疑问。 我知道 $ _ SERVER ['REMOTE_ADDR'] code>为我们提供了用户正在查看当前页面的IP地址 em>。 p>

我从以下方面获得了这样的解释: http://php.net/manual/en/reserved .variables.server.php 。 但是这个命令没有给我用户的IP地址。 它总是只给我托管IP地址 code>。 为什么? p>

有人可以解释这种情况吗? 幸运的是,我从github找到了一个代码片段,我可以使用这个新的计数器。 ( https://gist.github.com/cballou/2201933 ) p>

为什么只有 $ _ SERVER ['REMOTE_ADDR'] code>不起作用? p> div>

Because some other piece of software on the server is initiating the request. This can be caused by e.g. reverse proxies or load balancers, or it may be a result of being hacked. One of the 'HTTP_*' elements of the same array should give you the real address if the bounced request is legitimate, otherwise it's time to back up all your data, wipe the server, and start over.