首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >varnish后端VCC-编译器失败

varnish后端VCC-编译器失败
EN

Stack Overflow用户
提问于 2015-07-08 19:31:15
回答 2查看 4.4K关注 0票数 0

我想在我的SX服务器前面添加一个varnish代理,我有两个shows ip:192.168.0.100 ip: 192.168.0.101都可以在lan中工作,但重新启动varnish时显示编译错误

nano /etc/varnish/default.vcl

代码语言:javascript
复制
# 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时显示错误

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

发布于 2017-07-13 21:48:12

尽管@Redithion给出了这个例子,但Varnish 4.0的正确配置似乎是:

代码语言:javascript
复制
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();
}
票数 3
EN

Stack Overflow用户

发布于 2015-07-14 21:44:24

您似乎使用的是Varnish 4.0。在此版本中,控制器已被moved to VMODs

这是一个基于我从here获得的示例

代码语言:javascript
复制
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;”语句!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31291374

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档