Client IP from $_SERVER['REMOTE_ADDR'] is Always the Same

If your scripts use $_SERVER['REMOTE_ADDR'] to get the client's IP address, they will always show the same, internal IP address due to the load balancers used for hosting your site. You can get the client's remote IP using $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'] instead.

To prevent having to set this everywhere you call it, you can use the auto_prepend_file flag in a .htaccess to set $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'] for all your PHP scripts. See the Knowledgebase article on $_SERVER['DOCUMENT_ROOT'] for details on using this.

  • 11 Users Found This Useful
這篇文章有幫助嗎?

Related Articles

$_SERVER['DOCUMENT_ROOT'] Doesn't Include My Web Site Root Directory

Due to the clustered system of Apache servers used to handle PHP files, if you use...