我想在我的SX服务器前面添加一个varnish代理,我有两个shows ip:192.168.0.100 ip: 192.168.0.101都可以在lan中工作,但重新启动varnish时显示编译错误
nano /etc/varnish/default.vcl
# define our first nginx server
backend nginx01 {
.host = "192.168.0.100";
.port = "80";
}
# define our second nginx server
backend nginx02 {
.host = "192.168.0.101";
.port = "80";
}
# configure the load balancer
director nginx round-robin {
{ .backend = nginx01; }
{ .backend = nginx02; }
}
# When a request is made set the backend to the round-robin director named nginx
sub vcl_recv {
set req.backend = nginx;
}重新启动varnish时显示错误
root@Sproxy:~# service varnish restart
Message from VCC-compiler:
directors are now in directors VMOD.
('input' Line 30 Pos 1)
director nginx round-robin {
########--------------------
Running VCC-compiler failed, exited with 2
VCL compilation failed
* Syntax check failed, not restarting发布于 2017-07-13 21:48:12
尽管@Redithion给出了这个例子,但Varnish 4.0的正确配置似乎是:
vcl 4.0;
import directors;
backend nginx01 {
.host = "192.168.0.100";
.port = "80";
}
backend nginx02 {
.host = "192.168.0.101";
.port = "80";
}
sub vcl_init {
new nginx = directors.round_robin();
nginx.add_backend(nginx01);
nginx.add_backend(nginx02);
}
sub vcl_recv {
set req.backend_hint = nginx.backend();
}发布于 2015-07-14 21:44:24
您似乎使用的是Varnish 4.0。在此版本中,控制器已被moved to VMODs
这是一个基于我从here获得的示例
vcl 4.0;
# define first nginx server
backend nginx01 {
.host = "192.168.0.100";
.port = "80";
}
# define second nginx server
backend nginx02 {
.host = "192.168.0.101";
.port = "80";
}
sub vcl_init {
new cluster1 = directors.round_robin();
cluster1.add_backend(nginx01, 1.0);
cluster1.add_backend(nginx02, 1.0);
}
sub vcl_recv {
set req.backend_hint = cluster1.backend();
}提示:不要忘记“vcl4.0;”语句!
https://stackoverflow.com/questions/31291374
复制相似问题