【问题标题】:Varnish bypass a large fileVarnish绕过一个大文件
【发布时间】:2014-05-28 17:13:28
【问题描述】:

我在我的 Apache Web 服务器上安装了默认设置的 Varnish。 Apache 列出到 8080 端口,Varnish 列出到 80。

我在网站上几乎没有 100MB、500MB 和 1GB 大小的可下载文件

1GB 不工作,当你点击它会说页面不可用或连接被服务器关闭。其他两个工作正常,但我不确定这是否是下载它们的正确方法。

如何让 varnish 绕过这些文件并直接从 Web 服务器获取它们?

谢谢。

【问题讨论】:

    标签: apache caching varnish varnish-vcl


    【解决方案1】:

    这可以通过检查后端答案中的Content-Length 来完成,如果它大于某个大小,则用一些标记和restart 请求事务进行标记

    例如,Content-Length >=10,000,00 的文件应该通过管道传输:

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

    然后我们返回检查请求接收和解析。 在这里我们可以检查我们的标记并执行pipe

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

    【讨论】:

      【解决方案2】:

      在 varnish 4 中,应将 vcl_fetch 替换为 vcl_backend_response,参见 https://www.varnish-cache.org/docs/trunk/whats-new/upgrade-4.0.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-07-05
        • 1970-01-01
        • 2017-03-28
        • 2014-10-11
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多