清漆禁止查询string

我试图设置禁止在光油4.我有这在vcl_recv:

ban("req.http.host == " +req.http.host+" && req.url ~ "+req.url); return(synth(200, "Ban added")); 

当我提出请求时,它确实说了禁止添加,我确实看到它与varnishadm ban.list:

 1499676469.672070 0 req.http.host == something.com && req.url ~ /some/path?q=* 

除非它不起作用,否则不会失效。 如果我试图禁止path*它似乎适用于像“path.css”这样的“常规”文件,但是看起来它从不会使基于查询string的URL失效。 还有什么我需要做的是让它考虑查询string? 查询string是相当不可读的,充满了%代码,如果重要的话。

谢谢

我想你正在寻找PURGE 。 这将是更有效的,并将在PURGE请求中无效的任何URL请求。 在vcl_recv ,添加:

 if (req.method == "PURGE") { # If not allowed then a error 405 is returned if (!client.ip ~ purge) { return(synth(405, "This IP is not allowed to send PURGE requests.")); } return (purge); } 

接下来,使caching中的页面无效:

 curl -X PURGE http://127.0.0.1/your-super-request-with-params -H "Host: example.com" 

如果你真的想要BAN而不是(你真的必须?),那么不要使用REGEX匹配( ~ )来使特定的URL无效,因为它会更有可能解释? 和其他查询参数作为引擎标志。 所以:

 ban("req.http.host == " + req.http.host + " && req.url = " + req.url); return(synth(200, "Ban added"));