Skip to content

Varnish ESI blocks don't load when HTTPS is used site-wide #3897

Closed
@erikhansen

Description

@erikhansen

This issue is related to #2657 that the OP closed.

Steps to reproduce

  1. Install Magento 2.0.2 with sample data
  2. Configure all urls to load from HTTPS (e.g., set "Base URL" and "Secure Base URL" to https://example.dev)
  3. Load frontend and you'll see the navigation present.
  4. Configure and enable Varnish (see documentation)
  5. Load the frontend and you'll see the main navigation is missing:
    test_and_purging_and_banning_ _varnish_version_3_0_7_documentation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: Format is not validGate 1 Failed. Automatic verification of issue format is failedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for development

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions