我遇到了Varnish的问题,它适用于几个意见,然后生病…奇怪的是,它可以工作大约20或30个请求。 如果我直接调用Apache,它工作正常。 我在Debian Squeeze上运行Varnish Version:3.0.3-1,现在在端口80上运行Apache,在同一台服务器上运行端口8080上的Varnish。
我使用https://github.com/mattiasgeniar/varnish-3.0-configuration-templates作为我的VCL的基础,并修改了VCL来支持Concrete5。
任何人有任何线索我应该如何debugging呢?
backend default { .host = "127.0.0.1"; .port = "80"; .connect_timeout = 1.5s; .first_byte_timeout = 45s; .between_bytes_timeout = 30s; .probe = { .url = "/"; .timeout = 1s; .interval = 10s; .window = 10; .threshold = 8; } }
LOG
0 CLI - Rd ping 0 CLI - Wr 200 19 PONG 1353791312 1.0 0 CLI - Rd ping 0 CLI - Wr 200 19 PONG 1353791315 1.0 0 Backend_health - default Still sick 4--XR- 0 8 10 0.000689 0.000000 HTTP/1.1 301 Moved Permanently
(301是因为我检查www。)
你的后端正在响应301的健康检查; 默认情况下,只有200是预期的“健康”响应。 改变你的探测器:
.probe = { .url = "/"; .timeout = 1s; .interval = 10s; .window = 10; .threshold = 8; .expected_response = 301; }
编辑:
这就是为什么日志在一开始就恢复正常的原因,但是一段时间之后,它会逐渐下降,最终导致病态:.interval,.threshold和.window的设置 – 健康检查变得“不健康“但是他们没有考虑到工人病了,直到他们得到了足够的不良反应,把窗口里的成功数量降到了门槛以下
发生301是因为探测器发送一个请求与Host: 127.0.0.1而你的服务器期望一个Host: example.com (你的域名),所以它不匹配任何服务器,所以捕获所有的服务器redirect它。
为了避免这种情况,您可以在探针中使用.request而不是.url
.probe = { .request = "GET / HTTP/1.1" "Host: example.com" "Connection: close" "Accept: text/html" ; .timeout = 1s; .interval = 10s; .window = 10; .threshold = 8; }
这里是探针的参考