0

几天前,我已经在 Debian 8.4 64 位上部署了 Varnish 4.1.2 ...服务配置还可以,但是当我通过它开始流式传输时,流式传输冻结了 60 秒,然后再次自动开始运行接下来的 2 或 3 分钟再冻结 60 多岁。虽然我在 Varnish 3 中没有遇到这个问题...

这是我的清漆 4.1.2 配置...

默认.conf

> vcl 4.0;

import std; import directors; import querystring;

backend server1 {   .host = "192.168.4.1";   .probe = {
    .url = "/hls/newtv/index.m3u8";
    .interval  = 5s;
    .timeout   = 1s;
    .window    = 5;
    .threshold = 3;   } }

sub vcl_init {   new vdir = directors.round_robin();   vdir.add_backend(server1); }

sub vcl_recv {   set req.backend_hint = vdir.backend(); # send all traffic to the vdir director   set req.http.Host = regsub(req.http.Host, ":[0-9]+", "");   set req.url = std.querysort(req.url);


  if (req.url ~ "^[^?]*\.(m3u8)(\?.*)?$") {
    unset req.http.Cookie;
    return (hash);   }

  if (req.http.Authorization) {
    # Not cacheable by default
    return (pass);   }

  return (hash); } sub vcl_pipe {   if (req.http.upgrade) {
    set bereq.http.upgrade = req.http.upgrade;   }

  return (pipe); }

sub vcl_hash {

    if (req.method == "GET" || req.method == "HEAD") {
        hash_data(querystring.remove(req.url));
    }
    else {
        hash_data(req.url);
    }
    hash_data(req.http.host);
    return (lookup);

}

sub vcl_hit {

  if (obj.ttl >= 0s) {
    return (deliver);   }


  if (std.healthy(req.backend_hint)) {
    if (obj.ttl + 10s > 0s) {
      return (deliver);
    } else {
      return(fetch);
    }   } else {
      if (obj.ttl + obj.grace > 0s) {
      return (deliver);
    } else {
      return (fetch);
    }   } return (fetch); # Dead code, keep as a safeguard }

sub vcl_miss {   return (fetch); }

sub vcl_backend_response {   if (beresp.http.Surrogate-Control ~ "ESI/1.0") {
    unset beresp.http.Surrogate-Control;
    set beresp.do_esi = true;   }

  if (bereq.url ~ "^[^?]*\.(m3u8)(\?.*)?$") {
    unset beresp.http.set-cookie;   }

  if (bereq.url ~ "^[^?]*\.(m3u8)(\?.*)?$") {
    unset beresp.http.set-cookie;
    set beresp.do_stream = true;
    set beresp.do_gzip   = false;   }

  if (beresp.status == 301 || beresp.status == 302) {
    set beresp.http.Location = regsub(beresp.http.Location, ":[0-9]+", "");   }

  if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {
    return (abandon);   }

  set beresp.grace = 6h;

  return (deliver); }

sub vcl_deliver {

  if (obj.hits > 0) { # Add debug header to see if it's a HIT/MISS and the number of hits, disable when not needed
    set resp.http.X-Cache = "HIT";   } else { set resp.http.X-Cache = "MISS";   }

  set resp.http.X-Cache-Hits = obj.hits;

  return (deliver); }

sub vcl_purge {   if (req.method != "PURGE") {
    # restart request
    set req.http.X-Purge = "Yes";
    return(restart);   } }

sub vcl_synth {   if (resp.status == 720) {
    set resp.http.Location = resp.reason;
    set resp.status = 301;
    return (deliver);   } elseif (resp.status == 721) {
    set resp.http.Location = resp.reason;
    set resp.status = 302;
    return (deliver);   }

  return (deliver); }


sub vcl_fini {

  return (ok); }

和 /etc/default/varnish

START=yes
NFILES=131072
MEMLOCK=82000
DAEMON_OPTS="-a 192.168.2.1:80 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s malloc,256m"

谁能帮我解决问题!!!

提前致谢...

4

1 回答 1

0

我不认为这是配置问题。这听起来像是一个 Varnish 错误,我建议您将其归档到官方 bugtracker 中。

如果您赶时间,我建议您尝试一下,set beresp.do_stream = False但我不相信这会有所帮助。

于 2016-04-13T13:58:33.027 回答