gpt4 book ai didi

caching - Varnish 清除配置导致启动错误

转载 作者:行者123 更新时间:2023-12-03 17:45:24 24 4
gpt4 key购买 nike

我在Varnish中的清除配置有问题。我有一个如下配置的清除URL,但是在尝试启动该服务时也出现了一个错误。如果我注释掉这部分配置,该服务将启动而不会出现问题。有人对我要去哪里有任何想法吗?

干杯。

sub vcl_recv {
#purge all
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
if (req.url ~ "varnish/index/purgeall/key/#Fj1nzljh") {
purge_hash( ".*" );
}
}

启动时的错误消息显示为:
user@ubuntu:/var/www$ sudo service varnish start
* Starting HTTP accelerator varnishd [fail]
storage_file: filename: /var/lib/varnish/ubuntu/varnish_storage.bin size 1024 MB.
Message from VCC-compiler:
Expected an action, 'if', '{' or '}'
(input Line 18 Pos 7)
purge_hash( ".*" );
------##########---------
Running VCC-compiler failed, exit 1
VCL compilation failed
mark@ubuntu:/var/www$ sudo service varnish start
* Starting HTTP accelerator varnishd [fail]
storage_file: filename: /var/lib/varnish/ubuntu/varnish_storage.bin size 1024 MB.
Message from VCC-compiler:
Expected an action, 'if', '{' or '}'
(input Line 18 Pos 7)
purge_hash( ".*" );

最佳答案

在3.0.x中执行此操作的正确方法是这样的:

acl our_lan {
"localhost";
"10.0.0.0"/8;
"192.168.0.0"/16;
}

sub vcl_recv {
# ...
if (req.request == "PURGE") {
if (! (client.ip ~ our_lan)) {
error 405 "Not allowed.";
}
return (lookup);
}
# ...
}

sub vcl_hit {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
}

sub vcl_miss {
if (req.request == "PURGE") {
error 200 "OK: but URL not in cache.";
}
}

YMMV。

关于caching - Varnish 清除配置导致启动错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5745412/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com