2

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..

2 Answers 2

1

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).

1
  • Correct. To put it another way: either drop the ^ and $, or swap == for ~, in the line where you test for whether to set req.backend to app02.
    – BMDan
    Jun 20, 2013 at 15:37
0

I'm unsure since it looks quite obvious that director definition is wrong.

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

Should be:

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

You should also be using varnishadm to check backend health

varnishadm debug.health
2
  • that's the whole point, even though one of backends is commented out, there are no requests that going to other backend, but I already solve it and posted answer).
    – alexus
    Jun 22, 2013 at 15:25
  • Oh sorry, i missed it :(
    – NITEMAN
    Jun 24, 2013 at 15:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .