Skip to main content
All CollectionsTroubleshooting Front-Commerce
Why is the IP stored in Magento not the same as the customer’s IP?
Why is the IP stored in Magento not the same as the customer’s IP?

Depending on the Magento configuration and proxies, the IP provided to Magento can originate from the Front-Commerce host.

Pierre avatar
Written by Pierre
Updated over 2 years ago

The expected behavior

When you experience IPs from the front-commerce hosting instead of getting the customer IP stored in the order, you need to ensure your Magento provider is not changing the value of the X-Forwarded-For header.

How to troubleshoot it ?

To easily ensure if this value is altered you can temporarily add the following PHP script to the Magento instance at pub/fc-test-ip.php with the following content

<?php echo "<pre>" . print_r($_SERVER, true) . "</pre>"; ?>

Then call it using curl

curl -H "X-Forwarded-For: 66.66.66.66" https://<magento_url>/fc-test-ip.php | grep HTTP_X_FORWARDED_FOR

If you do not retrieve the IP passed in the X-Forwarded-For in the response, please contact your Magento provider to ensure this header and values pass through each proxy without being modified or removed

Did this answer your question?