後端取得失敗 - varnish 無法取得 drupal 後端

後端取得失敗 - varnish 無法取得 drupal 後端

我運行一個 drupal 7 應用程式(3 個後端),我有 3 個清漆伺服器不斷拒絕取得後端。我在這裡讀過很多類似的錯誤,但仍然無法解決我的問題,拋出 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 錯誤仍然存在,但我不認為它與我的清漆錯誤有關係:

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

我透過 fast-cgi 運行 nginx+php-fpm 。我真的不確定,清漆對後端的期望是什麼,導致它拒絕獲取它,

碰巧錯誤的 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 在我的後端而不是我的清漆上,但不確定,為什麼網站有時會加載,有時會拋出直接/可怕的“後端獲取失敗 503 - 大師冥想”。感謝您的寶貴幫助。

更新:

修復方法是停用 gzip。我的主頁上有一個空內容並重定向,因此,gzip+ header-content-length=0(空)觸發了一個紅旗來清漆,清漆標記為不健康,以壓縮大小為 0 的內容。停用 gzip 或將一些內容傳回伺服器回應可以解決此問題

答案1

在您中,.request您似乎沒有指定文件。我認為它因此嘗試加載您的整個 Drupal 網站作為探測器。您可以將其變更為:

"GET /sitehealth.html HTTP/1.1"

其中sitehealth.html只是探測器可以載入的簡單文字檔。

進一步排除故障,您可以完全停用探測器並看看這是否會產生影響?不透過快取直接存取網站時是否出現任何錯誤?

基本上,獲得可靠工作的最簡單的配置,然後一次添加一個附加功能,直到出現故障為止。

相關內容