docker-magento icon indicating copy to clipboard operation
docker-magento copied to clipboard

add varnish container with configurations

Open epolish opened this issue 4 years ago • 10 comments

epolish avatar Apr 01 '21 19:04 epolish

Is there a non-invasive way this can be implemented? Meaning, 95% of devs will not need this, but I'd like to provide Varnish as a capability, so long as the 95% can keep this disabled. It'd be nice to have an option to toggle Varnish on/off.

markshust avatar Oct 14 '21 17:10 markshust

There is a problem with ssl termination... Varnish can't handle ssl traffic itself... so we need something like nginx to proxy the traffic. But I'll research some options with varnish official ssl offloader - hitch

epolish avatar Oct 14 '21 18:10 epolish

And I can say that varnish is must have for developing in scope of magento cloud projects. Because we cannot much configure on nginx m2 cloud because we only have an access to fastly which is varnish...

epolish avatar Oct 14 '21 18:10 epolish

I'll do some research with it anyway

epolish avatar Oct 14 '21 18:10 epolish

Ok cool. This ticket may be related https://github.com/markshust/docker-magento/issues/243. Ideally, Nginx should sort of be executed outside of the scope of this project even, so this can provide the ability to run many Magento instances at once. This is probably part of a larger future update, but it's something I've been thinking about a lot.

markshust avatar Oct 15 '21 13:10 markshust

For multiple local instances like valet?

AlphaTeknovaAdmin avatar Oct 26 '21 20:10 AlphaTeknovaAdmin

add varnish container - good Idia! ability to run many Magento instances at once - it already looks like kubernetes is suitable here

chrom avatar Dec 23 '21 09:12 chrom

  • Added varnish to docker-compose.dev.yml and docker-compose.yml
  • Changed port from 80:8000 to 8080:8000 in nginx service of both files
  • Created new file images/varnish/4,0/Dockerfile with content FROM eeacms/varnish COPY varnish,vcl /etc/varinshconfd/. This is the Docker image for Varnisg 4 which will be used by Magento 2 (Varnsih 6 does not work) 4..Created a default config file for Varnsh at images\vanish\40\default,vc1 based on https://githubemagagioeea_dockerfilesblobmastermagentovarinshdefauitvc1 but modified it so that it works with our setup - see comments in this vc1 file above
  • Added a new backend default
  • Set the first_byte_timeout to 600s
  • Created an ACL for purge requests and added IP addresses of app, varnish, phpfpm and host docker gateway
  • In vcl_recv: If request method is PURGE then check if client ip matches with any one in the ACL created above else return 405 error code (Method not allowed) or 400 error code (X-Magento-Tags-Pattern or X-Pool header required). Also ban objects based on headers received from proxy server/load balancer i.e., X-Magento Tags Pattern & Pool respectively

what-the-diff[bot] avatar Dec 04 '22 21:12 what-the-diff[bot]

Anyone needs varnish can use this command for online setup:

curl -s https://raw.githubusercontent.com/mucan54/docker-magento-varnish/main/lib/onelinesetup | bash -s -- magento.test 2.4.6 community

mucan54 avatar May 21 '23 20:05 mucan54