Welcome! Log In Create A New Profile

Advanced

Content-Length and really sent bytes sometimes mismatch

Posted by brice95 
Content-Length and really sent bytes sometimes mismatch
March 27, 2018 07:53AM
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 !
Attachments:
open | download - css_truncated1.png (7.4 KB)
Re: Content-Length and really sent bytes sometimes mismatch
March 30, 2018 04:44PM
still occurs with nginx/1.13.10 (current mainline) ..
Re: Content-Length and really sent bytes sometimes mismatch
April 07, 2018 03:39PM
still occurs..
Re: Content-Length and really sent bytes sometimes mismatch
November 19, 2018 05:28AM
I've found the same problem with current stable Nginx-1.14.1 from nginx-repo on CentOS6.
There are two web-sites on this server, and problem occurs only on one of them.

Also I have many servers with nginx without this problem, so the problem may have some site-specific reasons, but I can't find any differences or strangeness in this environment.

The problem was resolved by installing Nginx-1.10.2 from epel repo.



Edited 1 time(s). Last edit at 11/19/2018 05:32AM by tekuchev.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 200
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready