All good day! I struggle for several days to solve the problem of 502 bad gateway nginx when I upload heavy files (10 MB). Files up to 5 MB are loaded without errors. I tried to change the settings of PHP and Nginx, but did not help. System configuration: Ubuntu 16.04, Nginx, PHP. The following error information is given in Nginx logs:

*17 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 109.252.90.170, server: ΠΌΠΎΠΉ_сайт.ru, request$ equest: "POST /sources/preview HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.2-fpm.sock:", host: "ΠΌΠΎΠΉ_сайт.ru", referrer: "https://ΠΌΠΎΠΉ_сайт.ru/" 

PHP settings:

 max_input_time = 600; max_execution_time = 600; pload_max_filesize = 100M; post_max_size = 100M; memory_limit = 256M; 

Nginx settings:

 fastcgi_buffers 8 128k; fastcgi_buffer_size 256k; client_max_body_size 100M; client_body_buffer_size 128k; client_header_buffer_size 2k; fastcgi_connect_timeout 6m; fastcgi_send_timeout 6m; fastcgi_read_timeout 6m; proxy_connect_timeout 6m; proxy_send_timeout 6m; proxy_read_timeout 6m; send_timeout 6m; client_header_timeout 6m; client_body_timeout 6m; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; 

I tried to create the file /etc/php/7.2/fpm/conf.d/30-user.ini, where I specified the settings:

 max_input_time = 600; max_execution_time = 600; pload_max_filesize = 100M; post_max_size = 100M; memory_limit = 256M; 

Through phpinfo () checked that all settings are used

What did I miss?

  • In general, you need a php-fpm log, nginx just reports that nothing came from there. There are a lot of options . Start with php-fpm log - Total Pusher
  • In php-frm logs, I see the following [05-Aug-2018 12:50:40] WARNING: [pool www] child 25173 exited on signal 9 (SIGKILL) after 30.296949 seconds from start - Andrey Pisarev
  • This is already something. 30 seconds ... show var_dump(ini_get('max_execution_time')); die; var_dump(ini_get('max_execution_time')); die; in the script that loads the files. - Total Pusher
  • Shows string(3) "600" - Andrey Pisarev
  • and what can be done 30 seconds? Is this file also processed, like XML? see memory consumption - Total Pusher

0