我需要清除或禁止已被不安全请求修改的缓存。我找到了一个似乎适用于 varnish 3.0 的解决方案;但我使用的是 varnish 4。这似乎不再是正确的语法。
sub vcl_recv {
if ( req.request == "POST" || req.request == "PUT" ) {
ban("req.url == " + req.url);
return(pass);
}
}
它给了我一个错误
Jun 26 17:43:21 test varnishd[2127]: Symbol not found: 'req.request' (expected type BOOL):
Jun 26 17:43:21 test varnishd[2127]: ('/etc/varnish/default.vcl' Line 13 Pos 10)
Jun 26 17:43:21 test varnishd[2127]: if ( req.request == "POST" || req.request == "PUT" ) {
Jun 26 17:43:21 test varnishd[2127]: ---------###########--------------------------------------
Jun 26 17:43:21 test varnishd[2127]: Running VCC-compiler failed, exited with 2
我该怎么做才能让 Varnish 清除/禁止不安全的请求?
谢谢。
答案1
在 Varnish 4 中,req.request 变成了 req.method。 https://www.varnish-cache.org/docs/4.0/whats-new/upgrading.html