Varnish error 503 service unavailable guru meditation

varnish

here is part of my varnish's configuration:

backend(s) & director(s):

# 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";
# 

whenever 6app02a backend is down on purpose, so 6app02b should've kicked in.. yet, whenever I run GET (see below):

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

I'm getting following through 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

I'm also seeing:

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

just to verify that backend IS responding:

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

So why is varnish is unable to communicate w/ backend? especially if I AM able to do it via GET..

Best Answer

Incorrectly defined req.http.host. That's what caused this issue, exact match vs. regex (i.e. there's no regex inside of an exact match).

Related Topic