后端获取失败 - Varnish 无法获取 Drupal 后端

后端获取失败 - Varnish 无法获取 Drupal 后端

我运行一个 drupal 7 应用程序(3 个后端),并且有 3 个 varnish 服务器不断拒绝获取后端。我在这里读到过很多类似的错误,但仍然无法解决我的问题,抛出 503 varnish fetch failed guru 冥想。我读过这里的所有帖子,似乎都建议设置高超时,我已将其设置为 600 秒,许多帖子不推荐 .probe,我有 round.robin(切换后端),这是我的后端配置:

backend project1 {
.host = "myhost.ip";
.port = "80";
.connect_timeout = 600s;
.first_byte_timeout = 600s;

.probe = {
.timeout = 600s;
.interval = 10s;
.window = 5;
.threshold = 2;
.request =
"GET HTTP/1.1"
"Host: example.com"
"Connection: close";
}
}

顺便说一下,我监控了我的错误日志和访问日志,我注意到我有太多这样的错误,但我不想让你有偏见。

[info] Client prematurely closed connection (broken pipe)

有时

reqv failed

顺便提一下,我还想提一下,我的 fast-cgi 错误仍然存​​在,但我不认为它与我的 varnish 错误有关:

Primary Script unknown  ......, fastcgi, upstream:127.0.0.1

我通过 fast-cgi 运行 nginx+php-fpm。我真的不确定,varnish 对后端有什么配置要求,导致它拒绝获取它,

之前碰巧错误的 nginx 配置导致了这个错误,所以这里是我的 nginx 配置:

user nginx nginx;
worker_processes 4;

error_log /var/log/nginx/error.log info;

events {
    worker_connections 8192;
    multi_accept    on;
    use epoll;
}
worker_rlimit_nofile 64000;
http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main
            '$remote_addr - $remote_user [$time_local] '
            '"$request" $status $bytes_sent '
            '"$http_referer" "$http_user_agent" ';

    client_header_timeout 10m;
    client_max_body_size 100m;
    client_body_timeout 10m;
    send_timeout 10m;
    client_body_buffer_size 3m;
    connection_pool_size 256;
    client_header_buffer_size 1k;
    large_client_header_buffers 4 2k;
    request_pool_size 32k;

    gzip            on;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";
    gzip_min_length 10240;
    gzip_proxied    expired no-cache no-store private auth;
    gzip_types      text/plain application/xml;

    open_file_cache         max=2000 inactive=20s;
    open_file_cache_valid   60s;
    open_file_cache_min_uses        5;
    open_file_cache_errors          off;

    output_buffers 1 32k;
    postpone_output 1460;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    fastcgi_send_timeout 1800;
    fastcgi_read_timeout 1800;
    fastcgi_connect_timeout 1800;
    fastcgi_ignore_client_abort on;
    keepalive_timeout 75 20;
    ignore_invalid_headers on;
    index index.html;

    server {
            listen 80;
            server_name  example.com;
            rewrite ^(.*) http://example.com$1 permanent;
            }
    server {
            listen 80;
            server_name www.example.com;
            access_log /var/log/nginx/access.log main;
            error_log /var/log/nginx/error.log info;              
            root /var/www/public;
            index index.php index.phtml index.html;
            autoindex on;

            gzip_types text/plain text/css application/json application/x-ja
vascript text/xml application/xml application/xml+rss text/javascript applicatio
n/javascript;

            location ~ \..*/*\.php$ {
                    return 403;
            }
            location ~^/sites/.*/private/{
                    return 403;
            }
            location ~^/sites/.*/files/* {
                    try_files $uri @rewrite;
            }
            location ~ (^|/)\. {
                    return 403;
            }

            location / {

                    try_files $uri @rewrite;
                    }
            location @rewrite {
                    rewrite ^ /index.php;

            }
            location ~ \.php$ {
                    try_files $uri @rewrite;
                    #fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_pass 127.0.0.1:9000;
                    fastcgi_index  index.php;
             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                    fastcgi_buffer_size 128k;
                    fastcgi_buffers 256 16k;
                    fastcgi_busy_buffers_size 256k;
                    fastcgi_temp_file_write_size 256k;
                    fastcgi_keep_conn       off;
                    include /etc/nginx/fastcgi_params;

                    }


            location ~* \.(jpg|jpeg|css|gif|png|js|ico|xml)$ {

                    try_files $uri $uri/ ;
                    access_log off;
                    log_not_found   off;
                    expires 30d;
                    }

}

有人能告诉我该从哪个方向调试这个问题吗?我很可能确定 pb 在我的后端而不是 varnish 上,但我不确定,为什么网站有时会加载,有时会直接/糟糕地抛出“后端获取失败 503 - guru 冥想”。感谢您的宝贵帮助。

更新:

解决方法是禁用 gzip。我的主页上有空内容并重定向,因此,gzip+header-content-length=0(空)触发了 varnish 的红旗,varnish 标记为不健康,无法压缩大小为 0 的内容。错误的标头。禁用 gzip 或将一些内容返回到服务器响应可以解决此问题

答案1

在您的文件中,.request您似乎没有指定文档。因此,我假设它正在尝试加载您的整个 Drupal 站点作为探测器。您可以将其更改为:

"GET /sitehealth.html HTTP/1.1"

其中sitehealth.html只是探测器可以加载的一个简单文本文件。

进一步的故障排除,您可以完全禁用探测器并查看是否有区别吗?直接访问网站而不通过缓存时是否会出现任何错误?

基本上,获得可靠工作的最简单的配置,然后一次添加一个附加功能,直到遇到故障为止。

相关内容