Matt,
I don't know whether its a code bug or some mis-configuration from my side. But this is how I fixed it by slight modification of code.
I just added 2 lines in the __construct of Piwik/core/Tracker/Visit.php to fix my issue.
The new lines were added to get the IP from X-Forwarded-For header instead of getting client-ip. Following are the details of code-change.
Code File : Piwik/core/Tracker/Visit.php
Added lines :
if (empty($forcedIpString)) {
$forcedIpString = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
/** Above this code, the $forcedIpString was coming Empty. The root cause could be to find out why $forcedIpString is coming empty at this location?.
Whole Function after change :
public function __construct($forcedIpString = null, $forcedDateTime = null, $authenticated = false)
{
$this->timestamp = time();
if (!empty($forcedDateTime)) {
if (!is_numeric($forcedDateTime)) {
$forcedDateTime = strtotime($forcedDateTime);
}
$this->timestamp = $forcedDateTime;
}
/* Start of : New code for fixing the real ip of geo-location */
if (empty($forcedIpString)) {
$forcedIpString = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
/* End of : New code for fixing the real ip of geo-location */
$ipString = $forcedIpString;
if (empty($ipString)) {
$ipString = Piwik_IP::getIpFromHeader();
}
$ip = Piwik_IP::P2N($ipString);
$this->ip = $ip;
$this->authenticated = $authenticated;
}
I don't know whether its a code bug or some mis-configuration from my side. But this is how I fixed it by slight modification of code.
I just added 2 lines in the __construct of Piwik/core/Tracker/Visit.php to fix my issue.
The new lines were added to get the IP from X-Forwarded-For header instead of getting client-ip. Following are the details of code-change.
Code File : Piwik/core/Tracker/Visit.php
Added lines :
if (empty($forcedIpString)) {
$forcedIpString = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
/** Above this code, the $forcedIpString was coming Empty. The root cause could be to find out why $forcedIpString is coming empty at this location?.
Whole Function after change :
public function __construct($forcedIpString = null, $forcedDateTime = null, $authenticated = false)
{
$this->timestamp = time();
if (!empty($forcedDateTime)) {
if (!is_numeric($forcedDateTime)) {
$forcedDateTime = strtotime($forcedDateTime);
}
$this->timestamp = $forcedDateTime;
}
/* Start of : New code for fixing the real ip of geo-location */
if (empty($forcedIpString)) {
$forcedIpString = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
/* End of : New code for fixing the real ip of geo-location */
$ipString = $forcedIpString;
if (empty($ipString)) {
$ipString = Piwik_IP::getIpFromHeader();
}
$ip = Piwik_IP::P2N($ipString);
$this->ip = $ip;
$this->authenticated = $authenticated;
}