Tuan-Anh Tran

Fix unable to download huge files with varnish

Posted on August 19, 2014  •  1 minutes  • 106 words

I recently stumble against a problem with my varnish setup. I couldn’t download any file (huge ones) from my webserver (nginx). The problem only seems to occur with varnish enabled.

A little Google-fu, I found that the problem indeed was caused by varnish because varnish was intefering (timeouts and post-processes) with the request from client.

The fix is simple: let client and server talk directly without varnish interfering using pipe.

sub vcl_recv {
  # condition to trigger pipe
  if (req.url ~ "^/path/or/file/extension/or/whatever/condition/you/have/") {
    return (pipe);
  }
}
...
sub vcl_pipe {
  set bereq.http.connection = "close";
}

Try wget your files again. It should be fixed now.

Follow me

Here's where I hang out in social media