Magento2: Exempt maintenance ip not working

Created on 28 Nov 2016  路  4Comments  路  Source: magento/magento2

After a clean install in magento 2.1.1 CE without sample data i've run into the issue that once i enabled and added an IP to the exepmtion list of the maintenance mode, this IP address seems to be overriden and not able to access the website as if the IP was not taken in count.

My setup is the next one:
PHP 7.0.13
Apache/2.4.10 (Debian)
nginx/1.10.1
varnish-4.0.2
mysql Ver 5.6

Steps to reproduce

Enable maintenance mode via ssh , once in the application folder
php bin/magento maintenance:enable --ip=xxx.xxx.xxx.xxx

xxx.xxx.xxx.xxx stands for my ip

_Actual result_
Once enabled i tried to access my website and goes directly to the 503 html page (like for everyone else no in the exemption list)
_Expected result_
Able to access my website while in maintenance mode.

As on this closed issue https://github.com/magento/magento2/issues/4219 , i having the same issue as this post. IP added on the exemption, however when i try to access its like i wasnt even added on the exemption list.

needs update

Most helpful comment

Here's a potential solution I found:

https://dev98.de/2017/01/02/how-to-add-alternative-http-headers-to-magento-2/

TLDR:
Create app/etc/ip-fix/di.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

    <type name="Magento\Framework\HTTP\PhpEnvironment\RemoteAddress">
        <arguments>
            <argument name="alternativeHeaders" xsi:type="array">
                <item name="x-forwarded-for" xsi:type="string">HTTP_X_FORWARDED_FOR</item>
            </argument>
        </arguments>
    </type>
</config>

All 4 comments

@wicho91 thank you for your feedback.
Please, format this issue according to the Issue reporting guidelines: with steps to reproduce, actual result and expected result.
Please, also identify which version of Magento you are running.
If you are looking for an advise please refer to the Community Forums or the Magento Stack Exchange site for technical questions. As GitHub issue tracker is intended for technical issues only.

hi @wicho91 thank you for your reporting, we will close this issue for now as no update more than 2 week was received, please feel free to write here or to open new issue if needed

You can configure Nginx in order to add the real IP when there is Varnish

set_real_ip_from    127.0.0.1; #Put the Ip of your varnish/proxy here
real_ip_header    X-Forwarded-For; #Put the Header that your varnish/proxy set

Here's a potential solution I found:

https://dev98.de/2017/01/02/how-to-add-alternative-http-headers-to-magento-2/

TLDR:
Create app/etc/ip-fix/di.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

    <type name="Magento\Framework\HTTP\PhpEnvironment\RemoteAddress">
        <arguments>
            <argument name="alternativeHeaders" xsi:type="array">
                <item name="x-forwarded-for" xsi:type="string">HTTP_X_FORWARDED_FOR</item>
            </argument>
        </arguments>
    </type>
</config>

Was this page helpful?
0 / 5 - 0 ratings