Nginx – net::ERR_CONTENT_LENGTH_MISMATCH on Nginx and SSL

nginxssl

I have a problem with one of my servers witch I cannot resolve. I keep getting net::ERR_CONTENT_LENGTH_MISMATCH in Chrome on images or css/js scripts. Nginx is not proxy, it's just serving files himself. The error doesn't appear every time and after i refresh the page it disappears. It appears on computers with a fast internet connection with the server (tested multiple networks). It also appears in firefox but has a different error message.
Iv'e tried to disable gzip on server, disabled files metdata cache, nothing worked. After a while I've discovered that this error appears only on https, not http. So I've tried to change SSL cyphers, changed the SSL certificate from Letsencrypt to Comodore, nothing worked. I've updated nginx, still the same problem.

user  nginx;

worker_processes  12;

error_log  /var/log/nginx/error.log crit;
pid        /var/run/nginx.pid;

events {
    worker_connections  20000;
    #use epoll;
    multi_accept on;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;


    #open_file_cache max=200000 inactive=20s;
    #open_file_cache_valid 30s;
    #open_file_cache_min_uses 2;
    #open_file_cache_errors off;

    open_file_cache off;




    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    error_log  /var/log/nginx/error.log error;

    access_log  /var/log/nginx/access.log  main;
    #access_log  off;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    server_tokens off;

    keepalive_timeout  60;
    keepalive_requests 1000;

    send_timeout 40;

    reset_timedout_connection on;
    proxy_buffering on;

    fastcgi_buffers 512 16k;
    fastcgi_buffer_size 128k;
    fastcgi_busy_buffers_size 512k;
    fastcgi_connect_timeout 20s;
    fastcgi_send_timeout 120s;
    fastcgi_read_timeout 120s;
    fastcgi_temp_file_write_size 512k;
    server_names_hash_bucket_size 100;



    client_body_buffer_size 2m;
    client_max_body_size 2000m;
    client_header_buffer_size 32k;
    #large_client_header_buffers 8 8k;

    gzip off;
    gzip_comp_level 4;
    gzip_vary on;
    gzip_min_length 2000;
    gzip_proxied expired no-cache no-store private auth;
    gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/javascript application/xml;
    #gzip_disable "MSIE [5-6]\.";


    include /etc/nginx/conf.d/*.conf;
}

For now I've disabled gzip.

My relevant vhost file is:

listen *:80;
listen *:443 ssl;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+AESGCM:EDH+AESGCM:EECDH:EDH:!MD5:!RC4:!LOW:!MEDIUM:!CAMELLIA:!ECDSA:!DES:!DSS:!3DES:!NULL;
ssl_certificate /path/to/cert.crt;
ssl_certificate_key /path/to/key.key;

The server is a 6 core Xeon with HT, 64 GB RAM and SSD. The SSD is 50% full. Network load is not very high. Any help would be greatly appreciated.

Best Answer

Reduce the SSL buffer size to 4k:

ssl_buffer_size 4k;

Documentation: https://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_buffer_size