Hello,
I'm facing a major issue with nginx, about bytes sent in the HTTPS Response that are sometimes different with the Content-Length header. It especially occurs on CSS files, and as a result my website is seen by my visitors as a very unprofessional one ...
Such issue is further illustrated with the screenshot in attachement. As you can clearly see, nginx in reverse proxy mode, sometimes truncates my contents, as shown in the firefox web console. In the example with a CSS file, the content-length is about 222000 bytes (and the real file too is), however nginx randomly returns only less than 15800 bytes. As a result, the CSS can't be loaded. In chrome console, I have the "Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH" error for each nginx length mismatch.
More in depth, my distribution is Debian 9 (stretch) in the lastest version. The nginx version is nginx/1.10.3, the lastest available in the Debian stable world, and configuration files are mainly turned to Debian/Nginx defaults. I have a first Debian server with nginx and php-fpm, that contains the statics and dynamic pages. I have a second Debian server with nginx alone, that act as ssl reverse proxy from the internet to the first server. The content-length mismatch seems to occurs when the reverse proxy is used, but I can't guarantee that. When reverse proxy is used, I can however guarantee that it occurs either on statics files (served by nginx) or dynamic pages served by PHP/FPM, so it is not a FPM issue.
There are a lot of people that go crazy with this major issue, and I can cite some related threads on it :
https://stackoverflow.com/questions/25993826/err-content-length-mismatch-on-nginx-and-proxy-on-chrome-when-loading-large-file
https://serverfault.com/questions/783218/nginx-in-reverse-proxy-content-length-mismatch-for-bigger-css-files
https://github.com/owncloud/client/issues/5706
I endup with theses unprofessional settings (like weird timeouts) found on the internet for the nginx reverse :
proxy_temp_file_write_size 64k;
proxy_connect_timeout 10080s;
proxy_send_timeout 10080;
proxy_read_timeout 10080;
proxy_buffer_size 64k;
proxy_buffers 16 32k;
proxy_busy_buffers_size 64k;
proxy_redirect off;
proxy_request_buffering off;
proxy_buffering off;
... and the issue sill appears ...
I also try to add the following to the fastcgi fpm config :
fastcgi_buffering off;
... and the issue sill appears ...
And to disable buffering at the FPM level (output_buffering = off)
... and the issue sill appears ...
To conclude, I'm very surprised that nginx that is usually associated to quality software, seems to suffers such major issues in stable repos. Could an engineer from the NGINX Inc. could help on this issue and bring a professional fix for that ? Thanks !