What are the limitations when trying to retrieve the real IP address of users using an anonymous proxy server?

When trying to retrieve the real IP address of users using an anonymous proxy server, a limitation arises because the proxy server masks the user's actual IP address. To solve this issue, you can check for specific headers that may contain the real IP address forwarded by the proxy server. One common header to look for is "X-Forwarded-For."

if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $real_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
    $real_ip = $_SERVER['REMOTE_ADDR'];
}

echo "Real IP Address: " . $real_ip;