Closed
Description
This issue is related to #2657 that the OP closed.
Steps to reproduce
- Install Magento 2.0.2 with sample data
- Configure all urls to load from HTTPS (e.g., set "Base URL" and "Secure Base URL" to https://example.dev)
- Load frontend and you'll see the navigation present.
- Configure and enable Varnish (see documentation)
- Load the frontend and you'll see the main navigation is missing:
Potential Solutions
1. Modify Varnish ESI to ignore HTTPS
Per this Stack Exchange answer, if you modify your /etc/sysconfig/varnish file and add -p feature=+esi_ignore_https
to the arguments passed to Varnish, the problem will be solved. For example:
DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
-f ${VARNISH_VCL_CONF} \
-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
-p feature=+esi_ignore_https \
-p thread_pool_min=${VARNISH_MIN_THREADS} \
-p thread_pool_max=${VARNISH_MAX_THREADS} \
-S ${VARNISH_SECRET_FILE} \
-s ${VARNISH_STORAGE}"
This solution is merely a workaround for the fact that Magento 2 returns HTTPS urls as ESI urls. Also, this option is only available in Varnish 4.
2. Modify Magento's \Magento\PageCache\Observer\ProcessLayoutRenderElement::_wrapEsi method to never return HTTP urls
Per the #2657 issue raised by @boldhedgehog, the proper solution is to modify Magento to only return HTTP urls to Varnish. How exactly this is handled is up for discussion, as I don't think it would be proper to simply replace "https" with "https".