Magento 2 https ssl missing navigation menu

This is due to the catalog.topnav block declared in /vendor/magento/module-theme/view/frontend/layout/default.xml having a ttl attribute. If Varnish is used, this allows the block to expire separately from the pages it is included on by utilizing Edge Side Includes (ESI).

As you can see in your case the ESI is not being parsed correctly and you are missing your menu when the frontend is configured to serve all pages over HTTPS.

This is because Varnish doesn't inherently support HTTPS, to get your site working with HTTPS you will have used an SSL termination proxy. But in this case, the ESI request is calling an HTTPS resource (https://www.ozonesmoke.com) and it turns out Varnish has a check in place to block this. That is unless you change a Varnish setting - See https://www.varnish-cache.org/docs/4.0/reference/varnishd.html?highlight=esi_ignore_https#feature .

You can test this by changing the setting at runtime by launching varnishadm and running the following command: param.set feature +esi_ignore_https.

If you want this to be permanent though, you can enable this feature in your /etc/sysconfig/varnish file by adding in -p feature=+esi_ignore_https \ into your DAEMON_OPTS, this will require a restart of Varnish to take effect.


I have created my own default.xml file at below location

/app/design/frontend/YOUR_COMPANY/YOUR_THEME/Magento_Theme/layout/default.xml

And I've added these lines into it:

<referenceBlock name="catalog.topnav" remove="true"/>

<referenceBlock name="store.menu">
    <block class="Magento\Theme\Block\Html\Topmenu" name="catalog.topnav.fix" template="Magento_Theme::html/topmenu.phtml" before="-"/>
</referenceBlock>

It's running for me without problems with Varnish.

Note: I've added "catalog.topnav" again without TTL parameter (just trying to remove or reset it doesn't work. It needs to be created again.)

Tags:

Magento2