I've been getting timeouts caused by a 502 bad gateway error on certain GET requests.
I've tried adding these lines to my nginx site conf file:
server {
client_max_body_size 500M;
client_header_timeout 3000;
client_body_timeout 3000;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_read_timeout 3000;
fastcgi_send_timeout 3000;
fastcgi_connect_timeout 3000;
fastcgi_buffers 128 256k;
fastcgi_buffer_size 256k;
}
}
I also tried tweaking the buffer sizes in the following ways:
fastcgi_buffers 256 512k;
fastcgi_buffer_size 512k;
fastcgi_buffers 64 128k;
fastcgi_buffer_size 128k;
fastcgi_buffers 32 64k;
fastcgi_buffer_size 64k;
I also tried changing PHP-FPM conf values to these:
max_execution_time = 3000
max_input_time = -1
memory_limit = 2048M
post_max_size = 500M
upload_max_filesize = 500M
opcache.memory_consumption = 1024
I also tried disabling OPCache.
So far none of this has alleviated the 502 error. Sometimes it times out at exactly 1 minute, sometimes it is 1.2 minutes according to the Chrome dev tools. I can't account for the variability in timeout.
When I check the site-specific nginx error log I see this error generated each time I try to access the URL:
[error] 20675#20675: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.72.213.137, server: example.com, request: "GET /data/123 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php7.1-fpm.sock:", host: "example.com"
Am I missing some key setting?
PHP 7.1
nginx 1.13.3
0 Answers