开源Varnish教程

2023-11-01 14:55:51 浏览数 (3)

检查命令

代码语言:javascript复制
curl -i 

安装目录中

代码语言:javascript复制
cd /etc/varnish

消空缓存

代码语言:javascript复制
varnishadm ban req.url "-" /

多后端配置服务

代码语言:javascript复制
acl ciilii {
"127.0.0.1";
"175.2.2.0"/24;
}
backend web1 {
.host ="11111"
.port = "80"
}
backend web2 {
.host ="22222"
.port = "80"
}
import directors from "/usr/lib64/varnish/vmods/libmod_directors.so";
sub vcl_int {
new lb = directors.round_robin();
lb.add_backend(web1);
lb.add_backend(web2);
}
sub vcl_recv {
if (req.http.host ~"^(www.)?ciilii.com"){
set req.http.host ="www.ciilii.com";
set req.backend_hint = lb.backend();
}elseif (req.http.host ~"^docker.ciilii.com") {
set req.backend_hint = web2;
}else{
return (synth(405));

}
if (req.method == "ban") {
if (!clint.ip ~ ciilii) {
return(synth(405,"Not Allow"));
}
ban("req.url ~"   req.url);
return(purge);
}
}

1 人点赞