简体   繁体   中英

How can configure the Magento 2 With Varnish Cache with HTTPS

Thank you for looking on this.

I have a Magento 2.1.8 website and it will run on the Amazon EC2 with this https://aws.amazon.com/marketplace/pp/B007OUYR4Y Amazon AMI.

I have optimized everything on Magento 2 website but did not get the proper result on this.

I have tried to use the Varnish cache but it is not working with the HTTPS.

anyone have an idea, how can use the varnish with the HTTPS to optimize the website speed.

Varnish Cache does dot speak HTTPS natively. You'll need an SSL terminator such as Hitch , HAProxy , etc. deployed in front of Varnish, ideally using the PROXY protocol.

With my setups I use NGINX as a proxy to handle both http and https requests and then use Varnish as the backend so NGINX handles all the SSL certificates.

Here's an example of my NGINX ssl template:

server {
    listen  server-ip:443 ssl;
    server_name example.com www.example.com;
    ssl_certificate  /home/user/conf/web/ssl.example.com.pem;
    ssl_certificate_key  /home/user/conf/web/ssl.example.com.key;

    location / {
      proxy_pass  http://varnish-ip:6081;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $remote_addr;
      proxy_set_header X-Forwarded-Proto https;
      proxy_set_header X-Nginx on;
      proxy_redirect     off;
    }

    location @fallback {
        proxy_pass  http://varnish-ip:6081;
    }


}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM