I'm trying to configure varnish for Magento2.
Question: I'm unable to configure PURGE varnish cache.
Here is my build: https://github.com/zhartaunik/magento2-docker
Varnish settings: https://github.com/zhartaunik/magento2-docker/tree/master/docker/varnish
I'm using docker-compose. Varnish FROM varnish:6.2 vcl 4.0;
I'm trying to configure purge command in a safe way. I'm not sure what is the best practice on how to configure varnish, but Magento recommends the following:
acl purge {
"nginx";
}
And there is following verification:
sub vcl_recv {
if (req.method == "PURGE") {
if (!client.ip ~ purge) {
return (synth(405, "Purging not allowed for " + client.ip));
}
In my case when I'm trying to purge varnish from console / admin UI - I'm always facing with the following error:
<!DOCTYPE html>
<html>
<head>
<title>405 Purging not allowed for 192.168.128.7</title>
</head>
<body>
<h1>Error 405 Purging not allowed for 192.168.128.7</h1>
<p>Purging not allowed for 192.168.128.7</p>
<h3>Guru Meditation:</h3>
<p>XID: 32770</p>
<hr>
<p>Varnish cache server</p>
</body>
</html>
After the docker restart, this IP address changes.
When I'm trying to configure acl purge with container names I'm still facing the same error. However, adding container name to "whitelist" and running
curl -k -X PURGE https://magento2.docker
Passes this verification.
What is the best and safest way to configure acl purge
section?