繁体   English   中英

如何修复上游从上游读取响应头时发送过大的头?

[英]how to fix upstream sent too big header while reading response header from upstream?

我的日志中有这个错误:

上游从上游读取响应头时发送了太大的头

我试着补充一下

proxy_buffer_size   128k;
proxy_buffers   4 256k;
proxy_busy_buffers_size   256k;

到我的nginx.conf http块但没有工作

我也尝试添加

fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;

到我的conf文件,但我找不到任何位置〜.php $ {

所以我想知道我怎么能克服这个错误? 加入

fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;

一个手工制作的php块给了我nginx:[emerg]未知指令“location”在/etc/nginx/nginx.conf:6

通常这个参数修复“上游发送过大的标题”问题,你不需要巨大的值:)并将它们设置为http或服务器块,而不是位置。

server {
...
    fastcgi_buffers  16 16k;
    fastcgi_buffer_size  32k;
}

有时FirePHP for Firefox会创建大标题,尝试暂时禁用它。

upstream sent too big header while reading response header from upstream是nginx的通用方式,说“我不喜欢我所看到的”

  1. 您的上游服务器线程崩溃了
  2. 上游服务器发回了无效的头
  3. 从STDERR发回的通知/警告打破了他们的缓冲区,它和STDOUT都关闭了

3:查看消息上方的错误日志,是否在消息之前使用记录的行进行流式处理? PHP message: PHP Notice: Undefined index:来自循环的示例片段我的日志文件:

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:
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行看到(从之前的20个错误中)缓冲区限制被击中,破坏,并且下一个线程在其中写入。 然后Nginx关闭连接并将502返回给客户端。

2:记录每个请求发送的所有标头,检查它们并确保它们符合标准(nginx不允许任何超过24小时的内容删除/过期cookie,发送无效内容长度,因为错误消息在内容计数之前被缓冲。 ..)

例子包括:

<?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:验证或制作脚本日志,以确保您的线程到达正确的终点并且在完成之前不退出。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM