使用HTTP和REGEX清除varnish [英] Varnish purge using HTTP and REGEX

查看:150
本文介绍了使用HTTP和REGEX清除varnish的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用HTTP清除我的清漆的元素。此http调用是从后端服务器在清漆本身后面触发的,因此后端服务器不具有其他访问权限,只有HTTP。

I want to purge Elements of my varnish using HTTP. This http call is triggered from a backend server behind the varnish itself, so the backend server has not other access but HTTP.

我已根据ACL实施了以下清除规则:

I have implemented the following purging rules with the according ACL which work fine for

curl -X PURGE http://www.example.com/image/123/photo-100-150.jpg

但我希望能够使用Regex通过HTTP清除网址

but I want to be able to purge an URL via HTTP using Regex

curl -X PURGE http://www.example.com/image/123/*.jpg

以在上传新图片后清除此图片的所有缩放版本。是否有办法?

That way I want to clear all scaled version of this image once a new has been uploaded. Is there a way?

推荐答案

请尝试:

3.0及以上。

vcl_recv {
    if (req.request == "PURGE") {
             if (!client.ip ~purge){
                     error 405 "Not allowed";
             }
     ban("req.http.host == " +req.http.host+" && req.url ~ "+req.url);
     error 200 "Ban added";

    }

这篇关于使用HTTP和REGEX清除varnish的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆