Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Facebook nginx大报头响应_Facebook_Nginx_Header - Fatal编程技术网

Facebook nginx大报头响应

Facebook nginx大报头响应,facebook,nginx,header,Facebook,Nginx,Header,“上游从上游读取响应标头时发送的标头太大” 当我尝试从facebook进行身份验证时,我一直都会得到这个消息。我增加了缓冲区: proxy_buffer_size 256k; proxy_buffers 8 256k; proxy_busy_buffers_size 512k; fastcgi_buffers 8 256k; fastcgi_buffer_size 128k; 但这似乎没有帮助。有没有想过为什么会发生这种情况 nginx.conf文件: user www-data;

“上游从上游读取响应标头时发送的标头太大”

当我尝试从facebook进行身份验证时,我一直都会得到这个消息。我增加了缓冲区:

proxy_buffer_size   256k;
proxy_buffers   8 256k;
proxy_busy_buffers_size   512k;
fastcgi_buffers 8 256k;
fastcgi_buffer_size 128k;
但这似乎没有帮助。有没有想过为什么会发生这种情况

nginx.conf文件:

user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    # multi_accept on;
}


http {
    include       /etc/nginx/mime.types;

proxy_buffer_size   256k;
proxy_buffers   8 256k;
proxy_busy_buffers_size   512k;
fastcgi_buffers 8 256k;
fastcgi_buffer_size 128k;

    access_log  /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}
/etc/nginx/站点已启用/默认

server {
    listen   80 default;
    server_name  localhost;

    access_log  /var/log/nginx/localhost.access.log;

    location / {
        root   /var/www/nginx-default;
        index  index.html index.htm;
    }

    location /doc {
        root   /usr/share;
        autoindex on;
        allow 127.0.0.1;
        deny all;
            }

    location /images {
        root   /usr/share;
        autoindex on;
    }
}

今天早上我也有同样的问题。然而,增加缓冲区大小对我来说是有效的。这是我使用的设置:

   proxy_buffer_size    128k;
   proxy_buffers     4 256k;
   proxy_busy_buffers_size 256k;
   proxy_temp_file_write_size 256k;
我在配置中没有看到的唯一设置是

   proxy_temp_file_write_size 256k;

另外,我只为vhost添加了这些值。我认为这不重要,但可能值得一试。

事实证明Codeigniter设置了自己的最大大小。我还没有弄明白如何限制这一点,但不幸的是,更改nginx不会改变任何事情。感谢VBart和gsharma提供的所有帮助。

在codeigniter中,我遇到了相同的错误。这对我很有用:

In.conf

location ~* \.php$ {
    fastcgi_pass 127.0.0.1:9001;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    # 16-sept-2012 parametros para evitar el 502
    fastcgi_temp_file_write_size 10m;
    fastcgi_busy_buffers_size 512k;
    fastcgi_buffer_size 512k;
    fastcgi_buffers 16 512k;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    fastcgi_intercept_errors on;
    fastcgi_next_upstream error invalid_header timeout http_500;
}

我在一个800字节长、4个标题的页面上遇到了这个错误。这是一个删除Cookie的注销页面。为了让饼干过期,我把它们放回我的生日。这在nginx中不起作用,它们必须在不到一个月的时间内过期才能通过验证以删除cookie

我对几个不同但无效的标题进行了检查,得到了相同的结果。如果nginx无法验证它抛出的头:上游从上游读取响应头时发送的头太大

2015年:更多来自经验的信息:
从上游读取响应头时上游发送的头太大
是nginx表示“我不喜欢我看到的东西”的通用方式

  • 上游服务器线程崩溃
  • 上游服务器发回了无效的头
  • 从STDERR返回的通知/警告破坏了它们的缓冲区,它和STDOUT都被关闭
  • 3:查看消息上方的错误日志,它是否与消息前面记录的行一起流式传输<代码>PHP消息: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:
    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:验证或创建脚本日志,以确保线程到达正确的端点,并且在完成之前不会退出。

    我们正在移动生产环境,旧的生产环境工作正常,并且存在相同的“上游发送的头太大,而从上游读取响应头”问题。这是一个Codeigniter 2.x应用程序

    正如@gsharma所说,在使用此命令更改服务器配置后,错误日志消失

        fastcgi_buffers 256 4k;
        fastcgi_buffer_size 8k;
    
    然而,仍然有一些问题:登录不再有效。 问题是$config['sess\u encrypt\u cookie']=TRUE

    当使用sess_encrypt_cookie时,Codeigniter尝试使用mcrypt库,但如果它不存在,则使用名为“_xor_encode”的方法。好的,我认为这种方法有缺陷

    安装php mcrypt后,一切正常


    (对不起我的英语)

    你用什么作为后端?nginx。我想我已经提到了,看起来我忘了。你确定吗?nginx如何从facebook进行身份验证?哦,你的意思是代码智能。我正在使用PHP。当facebook重定向到我的页面时,问题似乎发生在身份验证之后。PHP如何与nginx交互?你使用FastCGI吗?如果是这样,您能否显示相关的配置部分(使用
    fastcgi\u pass
    指令)?我也遇到了同样的问题,这个答案很有帮助。