Undefined index: proxy_client_headers

I’m running the WordPress plugin connected to Matomo in Self-Hosted (PHP API) mode, WP-Matomo 1.0.23 is successfully connected to Matomo 4.2.1. You are running WordPress 5.7.2.

In my server logs, I see a lot of warnings.

type	
E_NOTICE (8)
info	
Undefined index: proxy_client_headers
file	
/home/user/public_html/matomo/core/IP.php
line	
49

It seems to coincide with doing a GET request with query parameters, e.g.

example.org/?some=argument

Everything stills seems to work though, but it would be nice if there are isset() checks to avoid the warnings filling up people’s logs?

Hi,

The issue is most likely that some update didn’t update the config/global.ini.php to the latest version and now there are some options in it missing (and when Matomo tries to read those options, it fails)

I’d recommend you to replace the file with the correct one (either from the main Matomo download or from https://github.com/matomo-org/matomo/blob/4.2.1/config/global.ini.php)

Hi Lukas, thanks for your reply.

I checked the global.ini.php and it’s identical.

This was a new installation of Matomo, via Installatron. Could that cause issues?

Hi,

I don’t know how else to help.

The code from the error message:


looks into the [General] section of the Matomo config (first config.ini.php and then global.ini.php as a fallback) and searches for the proxy_client_headers option.

Maybe your config.ini.php isn’t a valid INI file and therefore breaks some settings.

It is hard to support installation methods created by others as they can arbitrary change Matomo code and therefore introduce their own bugs.

Thanks, I really appreciate the help. There is no proxy_client_headers in my config.ini.php, but it is in the global.ini.php, but all commented out.

What should I set it to?

; List of proxy headers for client IP addresses
; Matomo will determine the user IP by extracting the first IP address found in this proxy header.
;
; CloudFlare (CF-Connecting-IP)
;proxy_client_headers[] = HTTP_CF_CONNECTING_IP
;
; ISP proxy (Client-IP)
;proxy_client_headers[] = HTTP_CLIENT_IP
;
; de facto standard (X-Forwarded-For)
;proxy_client_headers[] = HTTP_X_FORWARDED_FOR

Hi,

Can you maybe check your core/IP.php if it looks like this?

Yes it looks the same:

public static function getIpFromHeader()
    {
        $general = Config::getInstance()->General;
        $clientHeaders = @$general['proxy_client_headers'];
        if (!is_array($clientHeaders)) {
            $clientHeaders = array();
        }

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

        $ipString = self::getNonProxyIpFromHeader($default, $clientHeaders);
        return IPUtils::sanitizeIp($ipString);
    }