0

I'm struggling with the fact that when having Nginx serving a 1.8 Gb file, when I put the URL in either Chrome or Firefox the download goes with 5 Mb/s, when I do it with wget or curl, same url, same client pc, the download goes with (my max.) 25 Mb/s. With Apache, serving the same file, it goes 25Mb/s with both browsers and curl/wget. My question is: why?

It's a pretty default config, I put either the X-Sendfile (apache2) or X-Accel-Redirect (Nginx) in the header, I've tried several configs with nginx, I can slow it down with limit_rate but not up. This is the location part of my default link in /etc/nginx/sites-enabled:

location files/ {
        internal;
        alias /var/www/html/;
        #directio 100m;
        output_buffers 2 512k;
        limit_rate 30000k;
        sendfile_max_chunk 0;

}

I turned on directio, left out or left in the other options, turned sendfile on/off, no difference.

  • With text based browser (lynx) it goes max speed 25 mb/s as well... – Niels Sep 21 '17 at 15:04
0

Apparently, Apache2 automatically fills out headers for size and file type, while Nginx, when none specified, uses text/html for type, and no size.

So, adding:

header("Content-Type: application/octet-stream");
header("Content-length: {$result[0]->size}");

Speeded the downloads up a factor ~ 5, working with my max. bandwidth.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.