清漆探针始终返回生病的后端

时间:2017-04-17 10:25:35

标签: apache virtualhost varnish varnish-vcl

我在端口80上运行Varnish,在同一台机器上运行8088端口的Apache(我用它进行开发/测试)。

Apache被定义为VCL中的后端,如下所示:

backend default {
    .host = "127.0.0.1";
    .port = "8088";
    .first_byte_timeout = 600s;
    .probe = {
        .request = "GET /index.php HTTP/1.1"
                "Host: example.com"
                "Connection: close";
        .interval = 5s;
        .timeout = 1s;
        .window = 10;
        .threshold = 8;
    }
}

如您所见,我设置了探针。但是,当我做varnishadm backend.list时,我得到了

Backend name                   Refs   Admin      Probe
default(127.0.0.1,,8088)       1      probe      Sick 0/10

当我执行wget 127.0.0.1:8088时,我得到了

--2017-04-17 10:20:20--  http://127.0.0.1:8088/
Connecting to 127.0.0.1:8088... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://magento2.dev/?SID=obcv7ifsq5b4ro9jr3hmpb7oi4 [following]
--2017-04-17 10:20:20--  http://magento2.dev/?SID=obcv7ifsq5b4ro9jr3hmpb7oi4
Resolving magento2.dev... 127.0.53.53
Connecting to magento2.dev|127.0.53.53|:80... connected.
HTTP request sent, awaiting response... 503 Backend fetch failed
2017-04-17 10:20:20 ERROR 503: Backend fetch failed.

那么探测器是否会收到503错误?因为请求是Varnish而不是Apache。或者我错了吗?

这里的记录是Apache的Virtualhost设置:

<VirtualHost *:8088>
     ServerAdmin admin@example.org
     ServerName magento2.dev
     ServerAlias www.magento2.dev
     DocumentRoot "/var/www/magento2/"
         CustomLog /var/log/httpd/magento2.dev-access.log combined
         ErrorLog /var/log/httpd/magento2.dev-error.log
     <Directory "/var/www/magento2/">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
     </Directory>
</VirtualHost>

任何想法都赞赏。

谢谢,

1 个答案:

答案 0 :(得分:6)

如果返回的HTTP状态为200 OK,则探测成功。目前,您的探针会重定向302 Found,因此它会将后端标记为生病。

您需要确保curl -IL http://127.0.0.1:8088/ -H "magento2.dev"不会返回任何重定向。 (Magento设置?)

以下命令在对病态后端进行故障排除时更有用,因为它会显示返回的HTTP状态:

varnishlog -g raw -i Backend_health