Downloads fail after all data downloaded on nginx + php-fpm.
I'm controlling downloads of zip files (roughly 100mb each) with a PHP script that streams the file directly to the client. I'm using php-fpm under Ubuntu 14.04 with nginx. Occasionally the download succeeds, but generally it fails after streaming all the data.
The download proceeds all the way to the end on both Chrome and Firefox client browsers, but then it hangs and fails. Sometimes the zip file just has the wrong name "foo.zip.crdownload" and sometimes it is corrupted. What can I do to debug this?
(Edit: nothing was showing in the logs, but finally a failed download showed up with "upstream timed out (110: Connection timed out) while reading response header from upstream, client")
I'm going through the CloudFlare CDN/Proxy, but the site was working through Apache 2 before today. I've disabled caching for the URL I'm downloading from. I also tried changing the mime type from 'application/octet-stream' to 'application/zip' and it still intermittently fails.