I have generally assumed that in a PHP script I can test $_SERVER['REMOTE_ADDR']
to establish the IP address from which the request originated. However, I am starting to wonder if things are not a bit more complicated. Here is the scenario
- I run a number of servers, call them A, B and C - on which users have to be "registered"
- I run a separate registration server, call it S, where the users' credentials etc are first verified prior to sending out a complete registration request to servers A, B and C
The request goes out as
file_get_contents('https://url?data=value')
On servers A, B and C I was quite naively testing $_SERVER['REMOTE_ADDR']
to establish that the request was in fact coming from server S. Much to my surprise the results turned out to be patchy and variable
- The value in
REMOTE_ADDR
was the IP address of the human user interacting with the registration server, S - The value in
REMOTE_ADDR
was the IP address of the registration server, S - what I had expected to see all the time - The value in
REMOTE_ADDR
was another IP address from the pool of IP addresses on the virtual server where I host server S
I don't really need to perform this additional verification test so I can drop it out altogether. Nevertheless this result has taken me by surprise so I am curious to see if someone here can shed some light on what is going on.
I should mention that I am running PHP 5.5 on Lighttpd on servers A, B and C and PHP 5.3 on Apache 2 on server S.