How do I configure Varnish for Magento 2 on a Cloudways managed hosting?

Step 1

bin/magento config:set system/full_page_cache/varnish/access_list 127.0.0.1

The default localhost value will not work on a Cloudways managed hosting.

Step 2

bin/magento config:set system/full_page_cache/varnish/backend_host 127.0.0.1

The default localhost value will not work on a Cloudways managed hosting.

Step 3

bin/magento config:set system/full_page_cache/varnish/backend_port 8080

The official Cloudways website provides a false information about the «Backend Port» Varnish setting in Magento 2 on a Cloudways managed hosting

Step 4

Ensure that http_cache_hosts is absent from app/etc/env.php.
If it presents, then remove it, and then run:

bin/magento setup:config:set

Result

2024-07-01--05-54-51