Magento

eCommerce Software for Online Growth

Magento Forum

From setting up your store to managing your products, pages and promotions to generating detailed reports, the Magento User Guide empowers the user to utilize the platform for all of its vast capacity.
Available in eBook and Print formats – Download Now!!!
   
Magento Logs Every Visitor with same IP address on Mosso [FIXED]
 
iseehow
Jr. Member
 
Avatar
Total Posts:  9
Joined:  2008-04-30
 

I know why this happens and I know what to fix, but I don’t know where to fix it. When Magento logs IP address using REMOTE_ADDR it logs Mosso’s Load Balancers.

So I was wondering if there is an easy fix to change the way Magento Logs IP address for “Online Customers” and when making a transaction? The proper way to log the IP on Mosso when an account has SSL is to use HTTP_X_FORWARDED_FOR (http://help.mosso.com/article.php?id=180) so the first and only thing I’ve tried so far was change System>Config>Web>Session Validation Settings to not validate using REMOTE_ADDR. Of course that didn’t change the way it logs the IP during a transaction. Where can I change the way Magento Logs IP addresses?

Please Help.... Thanks

THE FIX:

Find File: app\code\core\Mage\Log\Model\Visitor.php

Find Line 69: ‘remote_addr’ => empty($s[’REMOTE_ADDR’]) ? ‘’ : ip2long($s[’REMOTE_ADDR’]),

Change to: ‘remote_addr’ => empty($s[’HTTP_X_FORWARDED_FOR’]) ? ‘’ : ip2long($s[’HTTP_X_FORWARDED_FOR’]),

NOTE: This change is for SSL enabled site. If not SSL enabled then use “HTTP_X_CLUSTER_CLIENT_IP”

 Signature 

++Rockin Magento on the Cloud aka Mosso++

Wes
iSeeHow

 
Magento Community Magento Community
Magento Community
Magento Community
 
iseehow
Jr. Member
 
Avatar
Total Posts:  9
Joined:  2008-04-30
 

Just an update of the situation:

I did a backup then did a find and replace for REMOTE_ADDR to HTTP_X_FORWARDED. I emptied the sessions and cache in my browser and in Magento. The exact find and replace I did is the following:

$_SERVER[’REMOTE_ADDR’]
to
$_SERVER[’HTTP_X_FORWARDED’]

It seems to still be logging the Load Balancer IP address. So I guess I have two questions.

1. Is there a chance that Mosso, Magento or my Browser is somehow serving up something old?
2. Are there any cases (that you know of) that I should have left the code in Magento as $_SERVER[’REMOTE_ADDR’]?

Thanks for any insight you may have

 Signature 

++Rockin Magento on the Cloud aka Mosso++

Wes
iSeeHow

 
Magento Community Magento Community
Magento Community
Magento Community
 
iseehow
Jr. Member
 
Avatar
Total Posts:  9
Joined:  2008-04-30
 

I still need help with this, if anyone on Here has installed Magento on Mosso you must have run into this problem. I used Notepad++ to find all variations of “REMOTE_ADDR” in .php, .php3, phtml, & .xml files below are the results. I’m not sure I can do a simple find and replace for all instances of “REMOTE_ADDR” and help would be appreciated.

F:\Business\magento-1.3.0\magento\app\code\core\Mage\Adminhtml\Block\Customer\Online\Grid.php (1 hits)
Line 104: ‘index’=>’remote_addr’,
F:\Business\magento-1.3.0\magento\app\code\core\Mage\Core\etc\config.xml (2 hits)
Line 235: <use_remote_addr>1</use_remote_addr>
Line 235: <use_remote_addr>1</use_remote_addr>
F:\Business\magento-1.3.0\magento\app\code\core\Mage\Core\etc\system.xml (3 hits)
Line 1064: <use_remote_addr translate="label">
Line 1065: <label>Validate REMOTE_ADDR</label>
Line 1072: </use_remote_addr>
F:\Business\magento-1.3.0\magento\app\code\core\Mage\Core\Model\Session\Abstract\Varien.php (7 hits)
Line 34: const VALIDATOR_REMOTE_ADDR_KEY = ‘remote_addr’;
Line 34: const VALIDATOR_REMOTE_ADDR_KEY = ‘remote_addr’;
Line 246: * Use REMOTE_ADDR in validator key
Line 327: if ($this->useValidateRemoteAddr() && $sessionData[self::VALIDATOR_REMOTE_ADDR_KEY] != $validatorData[self::VALIDATOR_REMOTE_ADDR_KEY]) {
Line 327: if ($this->useValidateRemoteAddr() && $sessionData[self::VALIDATOR_REMOTE_ADDR_KEY] != $validatorData[self::VALIDATOR_REMOTE_ADDR_KEY]) {
Line 353: self::VALIDATOR_REMOTE_ADDR_KEY => ‘’,
Line 361: $parts[self::VALIDATOR_REMOTE_ADDR_KEY] = (string)$_SERVER[’HTTP_X_FORWARDED_FOR’];
F:\Business\magento-1.3.0\magento\app\code\core\Mage\Core\Model\Session\Abstract.php (4 hits)
Line 36: const XML_PATH_USE_REMOTE_ADDR = ‘web/session/use_remote_addr’;
Line 36: const XML_PATH_USE_REMOTE_ADDR = ‘web/session/use_remote_addr’;
Line 89: * Use REMOTE_ADDR in validator key
Line 95: $use = Mage::getStoreConfig(self::XML_PATH_USE_REMOTE_ADDR);
F:\Business\magento-1.3.0\magento\app\code\core\Mage\Log\Model\Mysql4\Customer.php (1 hits)
Line 113: ->joinInner($this->_visitorInfoTable, $this->_visitorTable.’.visitor_id=’.$this->_visitorInfoTable.’.visitor_id’, array(’http_referer’, ‘remote_addr’))
F:\Business\magento-1.3.0\magento\app\code\core\Mage\Log\Model\Mysql4\Visitor.php (1 hits)
Line 110: ‘remote_addr’ => $visitor->getRemoteAddr(),
F:\Business\magento-1.3.0\magento\app\code\core\Mage\Log\Model\Visitor.php (3 hits)
Line 69: ‘remote_addr’ => empty($s[’REMOTE_ADDR’]) ? ‘’ : ip2long($s[’REMOTE_ADDR’]),
Line 69: ‘remote_addr’ => empty($s[’REMOTE_ADDR’]) ? ‘’ : ip2long($s[’REMOTE_ADDR’]),
Line 69: ‘remote_addr’ => empty($s[’REMOTE_ADDR’]) ? ‘’ : ip2long($s[’REMOTE_ADDR’]),
F:\Business\magento-1.3.0\magento\app\code\core\Mage\Log\sql\log_setup\mysql4-install-0.7.0.php (1 hits)
Line 109: `remote_addr` bigint(20) default NULL,
F:\Business\magento-1.3.0\magento\app\code\core\Mage\Poll\controllers\VoteController.php (1 hits)
Line 49: ->setIpAddress(ip2long($this->getRequest()->getServer(’REMOTE_ADDR’)))
F:\Business\magento-1.3.0\magento\app\code\core\Mage\Rating\Model\Mysql4\Rating\Option.php (2 hits)
Line 94: $data[’remote_ip’] = $action->getRequest()->getServer(’REMOTE_ADDR’);
Line 95: $data[’remote_ip_long’] = ip2long($action->getRequest()->getServer(’REMOTE_ADDR’));

 Signature 

++Rockin Magento on the Cloud aka Mosso++

Wes
iSeeHow

 
Magento Community Magento Community
Magento Community
Magento Community
 
DavePit.com
Sr. Member
 
Avatar
Total Posts:  146
Joined:  2007-08-31
 

Did you happen to figure anything else out?  I’m stuck on the same issue, and the visitor.php doesn’t have the remote_addr code in it.

 Signature 

dpitMedia
Carbon Fiber Gear

 
Magento Community Magento Community
Magento Community
Magento Community
 
DavePit.com
Sr. Member
 
Avatar
Total Posts:  146
Joined:  2007-08-31
 

Here is the updated fix as of version 1.3.2.4 as the fix listed originally no longer applied.  The following issue occurs on Rackspace Cloud Sites (formerly known as Mosso).

The file needed to be modified is in /app/code/core/Mage/Core/Helper/Http.php

Instead of editing a core file, you should create a new file in the local version.  So copy the Http.php file above and put it here (you’ll probably have to create the directories):

/app/code/local/Mage/Core/Helper/Http.php

On line 141 you will see this:

$this->_remoteAddr $this->_getRequest()->getServer('REMOTE_ADDR');

If you are using SSL on your store, replace with this:

$this->_remoteAddr $this->_getRequest()->getServer('HTTP_X_FORWARDED_FOR');

If you are not using SSL on your store, replace with this:

$this->_remoteAddr $this->_getRequest()->getServer('HTTP_X_CLUSTER_CLIENT_IP');

Now your customers IP address should show on orders as well as “online customers”.

 Signature 

dpitMedia
Carbon Fiber Gear

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
© Copyright 2010 Magento Inc.
Privacy Policy|Terms of Service
Magento Community Count
194821 users|1327 users currently online|367397 forum posts