Even if it's an old question, I've had to check for proxy and unfortunatly none of the answers give good result.
After searching, I've found a better method. In order to understand this way of doing, just create a small page with this code:
$val)
{
echo $key."
\n";
}
?>
Run it direclty from your server. You'll see all keys from the header your server is sending. Then run the same script through a Proxy.
You'll see (depending on the Proxy) 3 possible results:
- the Proxy add news keys/values
- the Proxy don't send all the original keys/values so some are missing.
- the Proxy send exactly the same keys/values but not in same order
- the Proxy send exactly the same keys/values, in same order
The 4th case can happen but others are the most frequent.
So you just have to create an array with the key/value from your server (based on the result when you run the script without a Proxy) and compare the keys/values from $_SERVER. If you don't have exacty the same keys/values (less, more or in other order) you can assume the page came from a Proxy.
Notice I agree with those saying in some cases Proxy can be use in a "legal".