Apache 如何从varnish 3中排除虚拟主机?

Apache 如何从varnish 3中排除虚拟主机?,apache,virtualhost,varnish,varnish-vcl,Apache,Virtualhost,Varnish,Varnish Vcl,我想从varnish 3配置中排除单个虚拟主机 缓存:[www].domain.tld ### default.vcl backend foo { .host = "domain.tld"; .port = "8880"; } backend bar { .host = "host.domain.tld"; .port = "8880";} # ... if (req.url == "host.domain.tld") { set req.backend = bar; } if (req.ur

我想从varnish 3配置中排除单个虚拟主机

缓存:[www].domain.tld

### default.vcl
backend foo { .host = "domain.tld"; .port = "8880"; }
backend bar { .host = "host.domain.tld"; .port = "8880";}
# ...
if (req.url == "host.domain.tld") { set req.backend = bar; } 
if (req.url == "host.domain.tld") { return(pass); }
if (req.http.Cookie && req.url == "host.domain.tld") { return(pass); }

# ...

### httpd.conf
Listen 8880
<VirtualHost vhost.domain.tld:8880>
    DocumentRoot /var/www/foo/
    ServerName vhost.doman.tld
</VirtualHost>
不缓存:host.domain.tld

### default.vcl
backend foo { .host = "domain.tld"; .port = "8880"; }
backend bar { .host = "host.domain.tld"; .port = "8880";}
# ...
if (req.url == "host.domain.tld") { set req.backend = bar; } 
if (req.url == "host.domain.tld") { return(pass); }
if (req.http.Cookie && req.url == "host.domain.tld") { return(pass); }

# ...

### httpd.conf
Listen 8880
<VirtualHost vhost.domain.tld:8880>
    DocumentRoot /var/www/foo/
    ServerName vhost.doman.tld
</VirtualHost>
###default.vcl
后端foo{.host=“domain.tld”;.port=“8880”}
后端栏{.host=“host.domain.tld”;.port=“8880”}
# ...
如果(req.url==“host.domain.tld”){set req.backend=bar;}
if(req.url==“host.domain.tld”){return(pass);}
if(req.http.Cookie&&req.url==“host.domain.tld”){return(pass);}
# ...
###httpd.conf
听着,8880
DocumentRoot/var/www/foo/
服务器名vhost.doman.tld
请求从未到达虚拟主机。我想问题是我在端口80上请求,而主机在端口8880上侦听。

我能做些什么来解决这个问题

req.url
不包含域。你想要的是这样的东西:

sub vcl_recv {
  if (req.http.host == "host.domain.tld") {
    set req.backend = bar;
    return (pass);
  }
}
这会将任何到域“host.domain.tld”的请求的后端设置为“bar”,并直接传递到后端(绕过缓存)