PHP: if (getenv ("HTTP_X_FORWARDER")) { $ip = getenv ("HTTP_X_FORWARDER"); } else { $ip = $_SERVER ["REMOTE_ADDR"]; }