You can now set up Varnish cache for your Magento site through the Nimbus Hosting platform. Varnish is supported on our platform for our Oxygen package and higher and for sites running Magento 2.4 and newer.


Before getting started with Varnish you will need to install Magento 2.4 through the Nimbus Hosting platform following our guide which can be found below:

Installing Magento 2


Steps

  1. Once you have Magento 2.4 installed, you'll firstly need to configure Magento to use Varnish as the full page cache. To do this log into your Magento admin area and go to Stores > Settings > Configuration > Advanced > System > Full Page Cache

  2. Then select Varnish Caching from the caching application list.

  3. Next, navigate to the sites configuration page and toggle on the Varnish option.
  4. If all goes smoothly then the sites will start loading through Varnish. If you find it’s not worked and you see a message such as “503 backend fetch failed” then simply un-toggle the Varnish button in the platform and it will revert back to normal.

  5. You can confirm that requests are going though Varnish by logging onto the server via SSH and running the "varnishlog" command. 


Using a custom VCL file

When you enable Varnish from within the hosting app, we provide a default VCL file that's ready optimised for working on our servers. However you may wish to use a custom VCL file instead of the one we provide.


To export your sites custom VCL file navigate to the Magento 2 admin dashboard and export the sites Varnish config file. This can be found in:.

Stores> Configuration> Advanced> System> Full Page Cache> Varnish Caching> Export VCL for Varnish 6


Once you have the file, you will then need to upload this to the server and place it in the following location:


/etc/varnish/default.vcl


Then restart Varnish to active the new configuration.


Summary

For further reading and help with using Varnish on your website please see the Magento 2 developer documentation below:

https://devdocs.magento.com/guides/v2.4/config-guide/varnish/config-varnish.html