HA! Gotcha!
Figuring something out, especially after many frustrating moments, is quite rewarding. I only wish I didn't have to go through the frustration first...
At home, I have my personal website running off of Mac OS X, and I have been trying to get a simple PHP statement to behave as expected.
echo "$_SERVER['REMOTE_ADDR']";
should print out the IP address of the machine making he request to the HTTP server, but on my home system it printed out the internal address
of the server.
Let's just say that there were many frustrating moments trying to figure out
why.
In the hopes that
someone will benefit from my labors, here's what I found after many finely tuned Google searches, and ultimately ending up on
Apple's Discussion Boards:
By default, sites setup on X Server have a 'performance cache' turned on. Ultimately this means that the 'REMOTE_ADDR' environment variable in Apache gets set to the address of the performance cache (which seems to be another instance of Apache running on the same machine) so you end up with it pointing to the server address. Entirely not useful, especially if you're trying to do some
geolocating by IP address. After
some reading,
more, and
a little more, I discovered the source of the problem, and the likely cause for a persistent, yet unexplained, problem. The performance cache is a proxy serving off of port 16080 and, as mentioned, causes the "real" server to unwittingly populate the REMOTE_ADDR environment variable with the server's address. The performance cache was also responsible for the aforementioned persistent problem, which was generally confined to people accessing my site from a Windows based machine, without including a trailing 'slash' on the requested URL. In these circumstances, the page would not load, with some forgotten error message. I now believe that this was an artifact of the 16080 performance proxy and perhaps the configuration of my router's firewall. However, after disabling the performance cache on
all of the virtual hosts being served, by way of Apple's Server Admin application, both problems vanished, like an unsatisfactory meal, down the drain.
HA! Gotcha!