all of a sudden $_SERVER['REMOTE_ADDR'] is began coming back 10.10.10.10 php
I have to have skipped some rudimentary factor here.. However when I navigate for an IP-exhibiting site for example http://world wide web.whatsmyip.org/ they reveal a particular IP. However when I echo out
$_SERVER["REMOTE_ADDR"] on the page on my small site it shows another IP.
Can you explain that? And just how can one, through PHP, fetch exactly the same IP the whatsmyip.org site shows?
In case your computer is on a single network together with your server, behind a router with NAT, then you definitely might call at your private IP
Whenever your web server is in your local machine you'll have the local Ip mostly 127...1, that's because you aren't being able to access it from outdoors. That's reason.
What's the IP?
My only tought could be is you might b behind a proxy. Can it be?
It may be since you visit it from localhost? May be the IP the thing is 127...1, or perhaps your local IP (192.168.x.x)?
First of all allow me to clarify a couple of some misconception.
Whenever your on localhost your not making use of your Web service provider To fetch a web page, thus you would employ an interior ip of
::1 for ipv6.
In case your fetching the page from on the local network using a router of some type, you'll have an ip designated through the router for example
if your internet site is located outdoors the network then you definitely request your Web service provider to fetch the website for you personally, meaning you receive make use of the IP per whatsmyip.
in case your utilizing a DNS Server for example Opendns your asking your Web service provider to request Opendns to fetch the website for you personally, and open dns uses some ip's which are dissimilar to yours for apparent reasons.
there might be some kind of proxy that might be interfering, what exactly you want to do is counter for your, a typical proxy site should forward the clients IP onto the server incase associated with a direct connections needed as well as for other reasons.
This being stated you are able to usually discover the IP by checking other params before you decide to check
REMOTE_ADDR, this is a class I've produced for just one of my projects but you can easily take the thing you need:
foreach (array('HTTP_CLIENT_IP', 'HTTP_X_Submitted_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_Submitted_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) is available($key, $_SERVER) === true)
As you can tell an order from the array is essential:
REMOTE_ADDR comes last, the reason being this is actually the last measure and more often than not is incorrect.
In case your server is Apache and also you apply certain front-finish before Apache, you can test to make use of mod_rpaf:
aptitude install libapache2-mod-rpaf
then edit config:
<IfModule mod_rpaf.c> RPAFenable On RPAFsethostname Off RPAFproxy_insolvency practitioners 127...1 </IfModule>