应用配置:
Varnish有几个主要的配置,主配置(Management),总配置(Varnish),监控配置和后端配置。
主配置:Management进程的配置文件为/etc/varnish/varnish.params。这个配置文件,主要是修改端口和缓存类型及大小
监控配置和后端节点配置
监控配置
probe backend_healthcheck {
.request =
“GET /host.html HTTP/1.1”
“Host: slbtest.fishsaying.com”
“Connection: close”
“Accept-Encoding: gzip”;
.interval = 5s;
.timeout = 3s;
.window = 10;
.threshold = 2;
}
后端节点配置
import directors;
include “health_check.vcl”;backend Nginx1 {
.host = “10.252.102.218”;
.port = “80”;
.first_byte_timeout = 300s;
.connect_timeout = 5s;
.between_bytes_timeout = 2s;
.probe = backend_healthcheck;
}backend Nginx2 {
.host = “10.117.181.159”;
.port = “80”;
.first_byte_timeout = 300s;
.connect_timeout = 5s;
.between_bytes_timeout = 2s;
.probe = backend_healthcheck;
}backend Nginx3 {
.host = “10.117.31.137”;
.port = “80”;
.first_byte_timeout = 300s;
.connect_timeout = 5s;
.between_bytes_timeout = 2s;
.probe = backend_healthcheck;
}sub vcl_init {
new fsweb = directors.round_robin();
fsweb.add_backend(Nginx1);
fsweb.add_backend(Nginx2);
fsweb.add_backend(Nginx3);
}