我得到这样的错误:

2014/05/24 11:49:06 [error] 8376#0: *54031 upstream sent too big header while reading response header from upstream, client: 107.21.193.210, server: aamjanata.com, request: "GET /the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https://aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicles-sponsored-by-gujarat-government/,%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";
    }`

当前回答

Plesk指令

我把上面两个答案结合起来

在Plesk 12中,我让nginx作为反向代理运行(我认为这是默认的)。因此,当前顶部的答案不工作,因为nginx也作为代理运行。

我进入订阅|[订阅域]|网站和域(选项卡)|[虚拟主机域]| Web服务器设置。

然后在该页的底部,你可以设置附加nginx指令,我设置为上面两个答案的组合:

fastcgi_buffers         16  16k;
fastcgi_buffer_size         32k;
proxy_buffer_size          128k;
proxy_buffers            4 256k;
proxy_busy_buffers_size    256k;

其他回答

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

fastcgi_buffers 16 16k; 
fastcgi_buffer_size 32k;

在我们的例子中,我们得到了这个nginx错误,因为我们的后端生成了一个非常长的URL重定向响应:

HTTP/1.1 301 Moved Permanently 
Location: https://www.example.com/?manyParamsHere...

出于好奇,我们将这个大URL保存到一个文件中,它的大小为4.4 Kb。

在配置文件/etc/nginx/conf.d/some_site.conf中添加两行帮助我们修复了这个错误:

server {
    # ...
    location ~ ^/index\.php(/|$) {
        fastcgi_pass php-upstream;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        # Add these lines:
        fastcgi_buffer_size 32k;
        fastcgi_buffers 4 32k;
    }
}

在nginx官方文档中阅读更多关于这些参数的信息。

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

也就是说,对于ngx_http_proxy_module的用户

除了fastcgi,代理模块还将请求头保存在临时缓冲区中。

所以你可能还需要增加proxy_buffer_size和proxy_buffers,或者完全禁用它(请阅读nginx文档)。

代理缓存配置示例

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

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

http {
  proxy_buffering off;
}

欲了解更多信息:Nginx代理模块文档

upstream在读取upstream的响应头时发送了太大的头,这是nginx表示“我不喜欢我所看到的”的通用方式。

上游服务器线程崩溃 上游服务器发回无效报头 从STDERR发送回来的通知/警告溢出了它们的缓冲区,它和STDOUT都被关闭

3:查看消息上面的错误日志,它是否与消息前面的日志行一起流?PHP声明:未定义的索引: 示例片段从循环我的日志文件:

2015/11/23 10:30:02 [error] 32451#0: *580927 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined index: Firstname in /srv/www/classes/data_convert.php on line 1090
PHP message: PHP Notice:  Undefined index: Lastname in /srv/www/classes/data_convert.php on line 1090
... // 20 lines of same
PHP message: PHP Notice:  Undefined index: Firstname in /srv/www/classes/data_convert.php on line 1090
PHP message: PHP Notice:  Undefined index: Lastname in /srv/www/classes/data_convert.php on line 1090
PHP message: PHP Notice:  Undef
2015/11/23 10:30:02 [error] 32451#0: *580927 FastCGI sent in stderr: "ta_convert.php on line 1090
PHP message: PHP Notice:  Undefined index: Firstname

在从底部开始的第3行中,您可以看到缓冲区限制被击中,破坏了,下一个线程在它上面写入。然后Nginx关闭连接并返回502给客户端。

2:记录每个请求发送的所有报头,检查它们并确保它们符合标准(nginx不允许任何超过24小时的内容删除/过期cookie,发送无效的内容长度,因为错误消息在内容计数之前被缓冲了…)Getallheaders函数调用通常可以在抽象的代码情况下帮助解决PHP获取所有头文件的问题

例子包括:

<?php
//expire cookie
setcookie ( 'bookmark', '', strtotime('2012-01-01 00:00:00') );
// nginx will refuse this header response, too far past to accept
....
?>

这:

<?php
header('Content-type: image/jpg');
?>

<?php   //a space was injected into the output above this line
header('Content-length: ' . filesize('image.jpg') );
echo file_get_contents('image.jpg');
// error! the response is now 1-byte longer than header!!
?>

1:验证,或做一个脚本日志,以确保您的线程到达正确的终点,并在完成之前不退出。

我有这个错误,我找到了3种方法来修复它:

在.env: https://stackoverflow.com/a/69321273/13653732中设置shell_verbose =0或另一个< 3的值。在这种情况下,您将禁用PHP日志,但它们对开发和调试很有用。 fastcgi设置。在php.ini中Logging =0。与上述结果相同。 将Symfony从5.2更新到5.3。我认为旧版本在这方面有问题。

所有的PHP Symfony日志都被认为是Nginx的错误,但PHP工作正常。

我有Nginx 1.17, PHP 8.0.2, PHP- fpm, Symfony 5.2, Xdebug, Docker。

我尝试了新版本Nginx 1.21, PHP 8.0.14,但没有任何结果。这个问题不在于Apache。

我改变了Nginx的配置,但也没有任何结果。