清漆错误503服务不可用大师冥想

清漆错误503服务不可用大师冥想

varnish这是我的配置的一部分:

后端和控制器:

# cat backend-app02b.vcl 
backend app02b {
    .host = "192.168.52.153";
    .port = "80";
    .connect_timeout = 1s;
#   .first_byte_timeout = 5s;
    .between_bytes_timeout = 2s;
    .probe = probe1;
}
# cat backend-app02a.vcl
backend app02a {
    .host = "192.168.52.152";
#   .port = "http";
    .port = "80";
    .connect_timeout = 1s;
#   .first_byte_timeout = 5s;
    .between_bytes_timeout = 2s;
    .probe = probe1;
}
# cat backend-probe1.vcl 
// https://www.varnish-cache.org/trac/wiki/BackendPolling

probe probe1 {
    .url        = "/apc.php";
    .timeout    = 2s;
    .interval   = 5s;
    .window     = 5;
    .threshold  = 3;
}
# cat director-app02.vcl 
director app02 round-robin {
    { .backend = app02b; }
#   { .backend = app02a; }
}
# cat vcl_recv/req.http.host.vcl 
if  (req.http.host == "^XXX.XXX.XXX$" ) {
    set req.backend = app02;
}
# grep ^include default.vcl | grep -E 'backend|director'
include "backend-probe1.vcl";
include "backend-app02a.vcl";
include "backend-app02b.vcl";
include "director-app02.vcl";
# 

每当 6app02a 后端故意关闭时,6app02b 就应该启动...然而,每当我运行 GET 时(见下文):

# GET -HHost:XXX.XXX.XXX http://6svprx01/ -ds
503 Service Unavailable
# 

我正在关注varnishlog

4 SessionOpen  c 172.16.0.141 59555 172.16.0.141
4 ReqStart     c 172.16.0.141 59555 1934193781
4 RxRequest    c GET
4 RxURL        c /
4 RxProtocol   c HTTP/1.1
4 RxHeader     c TE: deflate,gzip;q=0.3
4 RxHeader     c Connection: TE, close
4 RxHeader     c Host: XXX.XXX.XXX
4 RxHeader     c User-Agent: lwp-request/5.827 libwww-perl/5.833
4 VCL_call     c recv
4 VCL_acl      c NO_MATCH e410
4 VCL_return   c lookup
4 VCL_call     c hash
4 Hash         c /
4 Hash         c XXX.XXX.XXX
4 VCL_return   c hash
4 VCL_call     c miss fetch
4 FetchError   c no backend connection
4 VCL_call     c error deliver
4 VCL_call     c deliver deliver
4 TxProtocol   c HTTP/1.1
4 TxStatus     c 503
4 TxResponse   c Service Unavailable
4 TxHeader     c Server: Varnish
4 TxHeader     c Content-Type: text/html; charset=utf-8
4 TxHeader     c Content-Length: 686
4 TxHeader     c Accept-Ranges: bytes
4 TxHeader     c Date: Thu, 13 Jun 2013 19:41:03 GMT
4 TxHeader     c X-Varnish: 1934193781
4 TxHeader     c Age: 0
4 TxHeader     c Via: 1.1 varnish
4 TxHeader     c Connection: close
4 TxHeader     c X-Served-By: 6svprx01.uftmasterad.org
4 TxHeader     c X-Cache: MISS
4 Length       c 686
4 ReqEnd       c 1934193781 1371152463.051303864 1371152463.052740097 0.000216484 0.001306057 0.000130177
4 SessionClose c error
4 StatSess     c 172.16.0.141 59555 0 1 1 0 0 0 295 686

我还看到:

0 Backend_health - app02b Still healthy 4--X-RH 5 3 5 0.010575 0.069739 HTTP/1.1 200 OK

只是为了验证后端回应:

[root@6svprx01 varnish]# GET -HHost:XXX.XXX.XXX http://6app02b/ -ds
200 OK
[root@6svprx01 varnish]# 

那么为什么varnish无法与后端通信?特别是如果我GET可以通过...来完成

答案1

定义不正确req.http.host。这就是导致此问题的原因,精确匹配与正则表达式(即精确匹配中没有正则表达式)。

答案2

我不确定,因为导演定义显然是错误的。

director app02 round-robin {
    { .backend = app02b; }
#   { .backend = app02a; }
}

应该:

director app02 round-robin {
    { .backend = app02b; }
    { .backend = app02a; }
}

你还应该使用 varnishadm 检查后端健康状况

varnishadm debug.health

相关内容