Tested it now with Varnish 4.0.1 and got it working with this in the default.vcl:
acl invalidators {
"127.0.0.1"
"localhost";
"<servers_hostname>";
"<servers_ip>";
}
sub vcl_recv {
if (req.method == "PURGE") {
if (!client.ip ~ invalidators) {
return (synth(405, "Not allowed"));
}
return (purge);
}
}
EDIT: I couldn’t get this to work before i added my servers public IP in the authorized client list. Edited the post to fit the results in case it might help someone else.