What are common errors or pitfalls when using PHP with a Reverse-Proxy?

One common error when using PHP with a Reverse-Proxy is that the server variables may not be properly set, leading to incorrect client IP addresses being logged or used in the application. To solve this, you can configure PHP to trust the Reverse-Proxy IP address by setting the `$_SERVER['REMOTE_ADDR']` variable to the correct client IP address provided by the Reverse-Proxy.

if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
}