Skip to content

Instantly share code, notes, and snippets.

@udovicic
Created September 14, 2023 11:29
Show Gist options
  • Save udovicic/30746ed5f745753451aad2bd908deb71 to your computer and use it in GitHub Desktop.
Save udovicic/30746ed5f745753451aad2bd908deb71 to your computer and use it in GitHub Desktop.
Magento 2 maintenance IPs when site is behind proxy
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- ... -->
<!-- Inside di.xml, place the following -->
<!-- Restore original visitor IP from CloudFlare header -->
<type name="Magento\Framework\HTTP\PhpEnvironment\RemoteAddress">
<arguments>
<argument name="alternativeHeaders" xsi:type="array">
<item name="http_cf_connecting_ip" xsi:type="string">HTTP_CF_CONNECTING_IP</item>
</argument>
</arguments>
</type>
<!-- ... -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment