上游在从上游读取响应标头时发送了太大的标头如果nginx作为代理/反向代理运行

我收到以下错误:

2014/05/24 11:49:06 [error] 8376#0: *54031 上游在从上游读取响应标头时发送了太大的标头, 客户端: 107.21.193.210, 服务器: aamjanata.com, 请求: “GET /the-洗脑-编年史-赞助-由古吉拉特邦政府/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsor-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsor-by-gujarat-government/,%20https:/aamjanata.com/由古吉拉特邦政府赞助的洗脑编年史/,%20https:/aamjanata.com/the-洗脑编年史-由古吉拉特邦政府赞助/,%20https:/aamjanata.com/洗脑编年史-由古吉拉特邦政府赞助/,%20https:/aamjanata.com/洗脑编年史-由古吉拉特邦政府赞助/,%20https:/aamjanata.com/洗脑编年史-由古吉拉特邦政府赞助/,%20https:/aamjanata.com/由古吉拉特邦政府赞助的洗脑编年史/,%20https:/aamjanata.com/the-洗脑编年史-由古吉拉特邦政府赞助/,%20https:/aamjanata.com/洗脑编年史-由古吉拉特邦政府赞助/,%20https:/aamjanata.com/洗脑编年史-由古吉拉特邦政府赞助/,%20https:/aamjanata.com/洗脑编年史-由古吉拉特邦政府赞助/,%20https:/aamjanata.com/洗脑编年史-由古吉拉特邦政府赞助/,%20https:/aamjanata.com/洗脑编年史-由古吉拉特邦政府赞助/,%20https:/aamjanata.com/洗脑编年史-由古吉拉特邦政府赞助/,%20https://aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-洗脑编年史-由古吉拉特邦政府赞助/,%20https:/aamjanata.com/由古吉拉特邦政府赞助的洗脑编年史/,%20https:/aamjanata.com/洗脑编年史-由古吉拉特邦政府赞助/,%20https:/aamjanata.com/洗脑编年史-由古吉拉特邦政府赞助/,%20https:/aamjanata.com/洗脑编年史-由古吉拉特邦政府赞助/,%20https:/aamjanata.com/洗脑编年史-由古吉拉特邦政府赞助/,%20ht

它总是一样的。一遍又一遍地重复的 url,以逗号分隔。无法弄清楚导致这种情况的原因。有人有想法吗?

更新:另一个错误:

http request count is zero while sending response to client

这是配置。还有其他不相关的东西,但这部分是添加/编辑的

fastcgi_cache_path /var/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
proxy_buffer_size   128k;
proxy_buffers   4 256k;
proxy_busy_buffers_size   256k;
    # Upstream to abstract backend connection(s) for PHP.
    upstream php {
            #this should match value of "listen" directive in php-fpm pool
            server unix:/var/run/php5-fpm.sock;
    }

然后在服务器块中:设置$skip_cache 0;

    # POST requests and urls with a query string should always go to PHP
    if ($request_method = POST) {
            set $skip_cache 1;
    }
    if ($query_string != "") {
            set $skip_cache 1;
    }

    # Don't cache uris containing the following segments
    if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
            set $skip_cache 1;
    }

    # Don't use the cache for logged in users or recent commenters
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
            set $skip_cache 1;
    }

    location / {
            # This is cool because no php is touched for static content.
            # include the "?$args" part so non-default permalinks doesn't break when using query string
            try_files $uri $uri/ /index.php?$args;
    }


    location ~ \.php$ {
            try_files $uri /index.php;
            include fastcgi_params;
            fastcgi_pass php;
            fastcgi_read_timeout 3000;

            fastcgi_cache_bypass $skip_cache;
            fastcgi_no_cache $skip_cache;

            fastcgi_cache WORDPRESS;
            fastcgi_cache_valid  60m;
    }

    location ~ /purge(/.*) {
        fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
    }`

答案 1

将以下内容添加到您的 conf 文件中

fastcgi_buffers 16 16k; 
fastcgi_buffer_size 32k;

答案 2

如果nginx作为代理/反向代理运行

也就是说,对于以下用户ngx_http_proxy_module

除此之外,该模块还将请求标头保存在临时缓冲区中。fastcgiproxy

因此,您可能还需要增加 和 ,或完全禁用它(请阅读 nginx 文档)。proxy_buffer_sizeproxy_buffers

代理缓冲配置示例

http {
  proxy_buffer_size   128k;
  proxy_buffers   4 256k;
  proxy_busy_buffers_size   256k;
}

禁用代理缓冲区的示例(建议用于长轮询服务器)

http {
  proxy_buffering off;
}

有关更多信息:Nginx 代理模块文档


推荐