Magento Varnish CWP template
For one of my projects I had to configure a server with a hosting panel (preferrably a free one) and an online store. The only mandatory request was to use varnish as a caching mechanism.
I’ve decided to use CWP since it provides an easy way to configure varnish and I came up with this setup:
Nginx will listen on ports 80 and 443 and gets hits directly by the visitors, Varnish comes in as a middle layer and does what it’s best at: Caching. Apache will actually server the website.
Since CWP doesn’t have a default varnish template for Magento I had to create one (the default is kinda different than the varnish template suggested by Magento).
You can find the template here: Magento2 Varnish CWP Template.
How to use it?
Login as root on the CWP server, go to /usr/local/cwpsrv/htdocs/resources/conf/web_servers/vhosts/varnish and save the template from github there.
Then login using ssh, as root, on the CWP server.
Select WebServers -> Select the last option -> Save & Rebuild
Once the rebuild is done:
WebServer Settings -> WebServers DomainConf -> Select a username -> Create a new Configuration -> Select the magento template for Varnish default vhost template -> Check Additional Options and hit Save Changes.