6

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

  • crashtestxxx how did you solve this? My braines are out of options.... – Jilco Tigchelaar Dec 24 '16 at 19:00
  • Yes, but it was not just as simple as I thought would be. I had to set up Nginx on port 443 as a proxy server, which passes requests to the Varnish on port 80, which handling HTTP requests, either from cache or to apache server to port 8080. – crashtestxxx Feb 21 '17 at 5:10
  • I also facing the same issue magento.stackexchange.com/questions/229527/… – Chirag Patel Jul 3 '18 at 5:11
11

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.

  • Thank you for your help. I have done everything as you guided. Added it in to my DAEMON_OPTS="-p feature=+esi_ignore_https \...". I using "alternative 3, if it makes any difference. Restarted varnish, got 2 [OK]'s and I still having a same problem. Any idea why it wouldn't be working in my case. I have also tried to run param.set feature +esi_ignore_https in varnishadm, got 200. But, I still not having any luck. – crashtestxxx Feb 3 '16 at 1:57
  • You need to determine why the ESI is not being processed by Varnish. I ran varnishlog and was able to see for my request a line stating ESI_xmlerror WARN at 6758 ESI 1.0 <esi:include> with https:// ignored which led me in the right direction. In your case it may be that Varnish calling the full SSL hostname in ESI is not able to resolve the name? You may need to add an entry to your hosts file for that hostname to the correct IP? – Tonegolf71 Feb 3 '16 at 9:08
  • 1
    @Tonegolf71 Thanks for your answer. I've raised an issue on the Magento 2 Github regarding this issue: github.com/magento/magento2/issues/3897 – Erik Hansen Mar 25 '16 at 21:12
  • How to change the settings with ssh? Is the a way to directly access the file? I can't find the etc folder in my magento and ssh doesn't recognise the mentioned commands.... – Jilco Tigchelaar Dec 17 '16 at 22:10
  • i added -p feature=+esi_ignore_https to varnish.params but not work – hkguile Mar 8 '18 at 10:22
4

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.)

1

I removed the TTL attribute from /vendor/magento/module-theme/view/frontend/layout/default.xml and the menu bar was there again! But can that do any harm, if I'm correct the default TTL is enheritated. Or am I wrong?

  • any drawback if apply this solution? – hkguile Mar 8 '18 at 10:27

protected by Community Apr 16 '17 at 19:37

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.