I am trying to configure Varnish cache on Magento 2.3 with SSL termination, but no luck so far.

Here is my configuration:


Listen 8080

<IfModule ssl_module>
        Listen 443

<IfModule mod_gnutls.c>
        Listen 443


<VirtualHost *:8080>


<VirtualHost *:8080>
     ServerAdmin contact@website.com
     DocumentRoot /var/www/html/magento2/
     ServerName website.com
     ServerAlias www.website.com

     <Directory /var/www/html/magento2/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

<VirtualHost *:443>
        ServerName website.com
        ServerAlias www.website.com
        DocumentRoot /var/www/html/magento2/

        ProxyPreserveHost on
        ProxyPass /
        RequestHeader set X-Forwarded-Port "443"
        RequestHeader set X-Forwarded-Proto "https"

        SSLEngine On
        SSLCertificateFile /etc/ssl/certs/website.com.crt
        SSLCertificateKeyFile /etc/ssl/private/website.com.key
        SSLCertificateChainFile /etc/ssl/website.com.ca-bundle
        <Directory /var/www/html/magento2/>
                Options Indexes FollowSymLinks MultiViews
                Order allow,deny
                AllowOverride All


backend default {
    .host = "";
    .port = "8080";
    .first_byte_timeout = 600s;
    .between_bytes_timeout = 600s;
    .probe = {
        .url = "pub/health_check.php";
        .timeout = 2s;
        .interval = 5s;
        .window = 10;
        .threshold = 5;


     -f ${VARNISH_VCL_CONF} \
     -p thread_pool_min=${VARNISH_MIN_THREADS} \
     -p thread_pool_max=${VARNISH_MAX_THREADS} \
     -p http_resp_hdr_len=65536 \
     -p http_resp_size=98304 \
 -p workspace_backend=98304 \

Magento Cache config:

Access list:
Backend host:
Backend port: 8080
Grace period: 300

Here is how my response headers look at this point:

Cache-Control: max-age=0, must-revalidate, no-cache, no-store
Connection: Keep-Alive
Content-Encoding: gzip
Content-Security-Policy: upgrade-insecure-requests
Content-Type: text/html; charset=UTF-8
Date: Fri, 22 Mar 2019 18:00:29 GMT
Expires: Thu, 22 Mar 2018 18:00:29 GMT
Keep-Alive: timeout=5, max=100
Pragma: no-cache
Server: Apache/2.4.29 (Ubuntu)
Set-Cookie: PHPSESSID=fh1hcnrcvs4u25lp1kqq7sv8br; expires=Fri, 22-Mar-2019 19:00:29 GMT; Max-Age=3600; path=/; domain=website.com; HttpOnly
Set-Cookie: form_key=Hu9gu1oJeyjVzCjm; expires=Fri, 22-Mar-2019 19:00:29 GMT; Max-Age=3600; path=/; domain=website.com
Strict-Transport-Security: max-age=31536000
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-UA-Compatible: IE=edge
X-XSS-Protection: 1; mode=block

Can anyone help with this issue? Thanks in advance!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.