Question

I have Varnish installed with the default setting on my Apache web server. Apache listing to port 8080 and Varnish listing to 80.

I have few downloadable files on the website with the sizes 100MB, 500MB and 1GB

The 1GB is not working, when you click on it it will say unavailable page or connection closed by server. The other two are working fine but I'm not sure if this is the correct way to download them.

How do I make varnish bypass these files and get them directly from the web server?

Thank you.

Was it helpful?

Solution

This could be done with check of Content-Length in backend answer, and if it larger than some size, then tag it with some mark and restart request transaction

Example, files with Content-Length >=10,000,00 should be piped:

sub vcl_fetch {
..
  if ( beresp.http.Content-Length ~ "[0-9]{8,}" ) {
     set req.http.x-pipe-mark = "1";
     return(restart);
  }
..
}

Then we returned back to checking request receiving and parsing. Here we can check our mark and perform pipe

sub vcl_recv {
..
  if (req.http.x-pipe-mark && req.restarts > 0) {
    return(pipe);
  }
..
}

OTHER TIPS

In varnish 4, vcl_fetch should be replaced with vcl_backend_response, see https://www.varnish-cache.org/docs/trunk/whats-new/upgrade-4.0.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top