清漆后端VCC编译器失败

时间:2015-07-08 11:31:15

标签: reverse-proxy varnish

我想在我的SX服务器前面添加一个清漆代理我有两个小滴ip:192.168.0.100 ip:192.168.0.101两个都在局域网中工作,但重启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;
}

重新启动清漆时显示错误

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

1 个答案:

答案 0 :(得分:0)

尽管@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();
}