add varnish container with configurations
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.
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
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...
I'll do some research with it anyway
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.
For multiple local instances like valet?
add varnish container - good Idia! ability to run many Magento instances at once - it already looks like kubernetes is suitable here
- 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
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