Magento2 HTTPS SSL – Fixing Missing Navigation Menu

magento2

My problem is when I load the home page with https, my navigation menu completely disappears.

In STORES > Configuration > GENERAL > Web, my Base URLs set to http://www.ozonesmoke.com/, and Base URLs (secure) set to https://www.ozonesmoke.com/.

Also my Use Secure URLs on Storefront is set to YES.
For some reason, not sure if it is intended, but the only time page loads with https is at the cart.

When I change Base URLs from http:// to https://, Magento 2 hides the navigation bar, and instead I see this tag inside, where originally supposed to be my site URL links.

<esi:include src="https://www.ozonesmoke.com/page_cache/block/esi/blocks/[%22catalog.topnav%22]/handles/[%22default%22,%22cms_index_index%22,%22cms_page_view%22,%22cms_index_index_id_home%22]/"></esi:include>

Is this a bug, or how can I set Magento, to always load pages with HTTPS?

Any help is greatly appreciated.

At the moment I running Magento 2.0.2 and Varnish-4.0.3

Best Answer

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.

Related Topic