K
K
Kichee2013-12-26 15:01:25
Nginx
Kichee, 2013-12-26 15:01:25

How to defeat Nginx "upstream closed prematurely" error?

In the NGINX error logs I get:

upstream sent too big header while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: domain.ru, request: "POST /....../......./ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: ".........", referrer: "................"

Writing the following lines did not help (fastsgi or fpm too):
proxy_buffers 8 16k;
proxy_buffer_size 32k;
Please tell me what could be the problem, the entire server config is below:
server {
          listen 80;
          server_name domain.ru www.domain.ru;
          root /home/www/docs/domain.ru;

          location / {
                  try_files $uri $uri/ /index.php?q=$uri&$args;
                  index index.php index.html index.htm;
          }

          location ~ \.php$ {
                  fastcgi_pass unix:/var/run/php5-fpm.sock;
                  fastcgi_index  index.php;
                  fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                  include        fastcgi_params;
          }
        proxy_buffers 8 16k;
        proxy_buffer_size 32k;
  }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolai Vasilchuk, 2013-12-26
@Anonym

Because it needs to be

fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;

If that doesn't help, try adding these lines to the section httpinstead ofserver

I
Ilya Evseev, 2013-12-26
@IlyaEvseev

Replacing unix:/var/run/php5-fpm.sock with 127.0.0.1:9000 doesn't help?
At least there it will be possible to listen with a sniffer.
Maybe PHP really produces an incorrect answer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question