- 论坛徽章:
- 0
|
使用版本:varnish2.0.4
启动参数:
./varnishd -n /data0/vcache -f /data0/varnish/vcl.conf -a 0.0.0.0:80 -s file,/data0/vcache/varnish_cache.data,1G -g www -u www -T 127.0.0.1:3500 -p client_http11=on
访问后端的网站出现如下情况:
- Error 503 Service Unavailable
- Service Unavailable
- Guru Meditation:
- XID: 1811196325
- Varnish
复制代码
配置文件如下:
backend myblogserver {
.host = "10.10.6.48";
.port = "8088";
}
acl purge {
"localhost";
"127.0.0.1";
"192.168.11.0"/24;
}
sub vcl_recv {
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
lookup;
}
if (req.http.host ~ "^mai.sina.cn") {
set req.backend = myblogserver;
if (req.request != "GET" && req.request != "HEAD") {
pipe;
}
else {
lookup;
}
}
else {
error 404 "the server is wrong!";
lookup;
}
}
sub vcl_hit {
if (req.request == "PURGE") {
set obj.ttl = 0s;
error 200 "Purged.";
}
}
sub vcl_miss {
if (req.request == "PURGE") {
error 404 "Not in cache.";
}
}
sub vcl_fetch {
if (req.request == "GET" && req.url ~ "\.(txt|js)$") {
set obj.ttl = 10s;
}
else {
set obj.ttl = 30d;
}
}
[ 本帖最后由 crisman 于 2009-7-14 11:11 编辑 ] |
|