upstream sent too big header while reading response header from upstream

前端 未结 8 821
醉梦人生
醉梦人生 2020-11-27 09:33

I am getting these kind of errors:

2014/05/24 11:49:06 [error] 8376#0: *54031 upstream sent too big header while reading response header from upstream

相关标签:
8条回答
  • 2020-11-27 10:12

    If nginx is running as a proxy / reverse proxy

    that is, for users of ngx_http_proxy_module

    In addition to fastcgi, the proxy module also saves the request header in a temporary buffer.

    So you may need also to increase the proxy_buffer_size and the proxy_buffers, or disable it totally (Please read the nginx documentation).

    Example of proxy buffering configuration

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

    Example of disabling your proxy buffer (recommended for long polling servers)

    http {
      proxy_buffering off;
    }
    

    For more information: Nginx proxy module documentation

    0 讨论(0)
  • 2020-11-27 10:12

    I am not sure that the issue is related to what header php is sending. Make sure that the buffering is enabled. The simple way is to create a proxy.conf file:

    proxy_redirect          off;
    proxy_set_header        Host            $host;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    client_max_body_size    100m;
    client_body_buffer_size 128k;
    proxy_connect_timeout   90;
    proxy_send_timeout      90;
    proxy_read_timeout      90;
    proxy_buffering         on;
    proxy_buffer_size       128k;
    proxy_buffers           4 256k;
    proxy_busy_buffers_size 256k;
    

    And a fascgi.conf file:

    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param  QUERY_STRING       $query_string;
    fastcgi_param  REQUEST_METHOD     $request_method;
    fastcgi_param  CONTENT_TYPE       $content_type;
    fastcgi_param  CONTENT_LENGTH     $content_length;
    fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
    fastcgi_param  REQUEST_URI        $request_uri;
    fastcgi_param  DOCUMENT_URI       $document_uri;
    fastcgi_param  DOCUMENT_ROOT      $document_root;
    fastcgi_param  SERVER_PROTOCOL    $server_protocol;
    fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
    fastcgi_param  REMOTE_ADDR        $remote_addr;
    fastcgi_param  REMOTE_PORT        $remote_port;
    fastcgi_param  SERVER_ADDR        $server_addr;
    fastcgi_param  SERVER_PORT        $server_port;
    fastcgi_param  SERVER_NAME        $server_name;
    fastcgi_buffers 128 4096k;
    fastcgi_buffer_size 4096k;
    fastcgi_index  index.php;
    fastcgi_param  REDIRECT_STATUS    200;
    

    Next you need to call them in your default config server this way:

    http {
      include    /etc/nginx/mime.types;
      include    /etc/nginx/proxy.conf;
      include    /etc/nginx/fastcgi.conf;
      index    index.html index.htm index.php;
      log_format   main '$remote_addr - $remote_user [$time_local]  $status '
        '"$request" $body_bytes_sent "$http_referer" '
        '"$http_user_agent" "$http_x_forwarded_for"';
      #access_log   /logs/access.log  main;
      sendfile     on;
      tcp_nopush   on;
     # ........
    }
    
    0 讨论(0)
提交回复
热议问题