- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个Varnish设置,可以将某些特定的URL(主要是XML输出)缓存5-10秒。 DC家伙设置了它并创建了配置文件,但是不幸的是它无法正常工作。
如果您能看一下配置并帮助我发现问题,我将非常高兴。
这是我的default.vcl
backend default {
.host = "127.0.0.1";
.port = "80";
}
sub vcl_recv {
if (req.restarts == 0) {
if (req.http.x-forwarded-for) {
set req.http.X-Forwarded-For =
req.http.X-Forwarded-For + ", " + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
}
if (req.request != "GET" &&
req.request != "HEAD" &&
req.request != "PUT" &&
req.request != "POST" &&
req.request != "TRACE" &&
req.request != "OPTIONS" &&
req.request != "DELETE") {
/* Non-RFC2616 or CONNECT which is weird. */
return (pipe);
}
if (req.request != "GET" && req.request != "HEAD") {
/* We only deal with GET and HEAD by default */
return (pass);
}
if (req.http.Authorization || req.http.Cookie) {
/* Not cacheable by default */
return (pass);
}
if(req.http.host == "foo.example1.com"){
if(req.url ~ "^/somedir\?somevar=anothervar&andanother=.*"){
return (lookup);
}
}else if(req.http.host == "bar.example2.com"){
if(req.url ~ "^/foo/bar\?somevar=anothervar&andanother=.*"){
return (lookup);
}
} else {
return (pass);
}
# Currently not reached.
return (lookup);
}
sub vcl_pipe {
# Note that only the first request to the backend will have
# X-Forwarded-For set. If you use X-Forwarded-For and want to
# have it set for all requests, make sure to have:
# set bereq.http.connection = "close";
# here. It is not set by default as it might break some broken web
# applications, like IIS with NTLM authentication.
return (pipe);
}
sub vcl_hash {
hash_data(req.url);
if (req.http.host) {
hash_data(req.http.host);
} else {
hash_data(server.ip);
}
return (hash);
}
sub vcl_miss {
return (fetch);
}
sub vcl_fetch {
if (beresp.ttl <= 0s ||
beresp.http.Set-Cookie ||
beresp.http.Vary == "*") {
/*
* Mark as "Hit-For-Pass" for the next 2 minutes
*/
set beresp.ttl = 120 s;
return (hit_for_pass);
}
set beresp.ttl = 5 s;
return (deliver);
}
curl --verbose --header 'Host: foo.example1.com' "http://127.0.0.1:6081/somedir?somevar=anothervar&andanother=123456"
是;
14 BackendClose b default
14 BackendOpen b default 127.0.0.1 60502 127.0.0.1 80
14 TxRequest b GET
14 TxURL b /somedir?somevar=anothervar&andanother=123456
14 TxProtocol b HTTP/1.1
14 TxHeader b User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.13.1.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2
14 TxHeader b Accept: */*
14 TxHeader b Host: foo.example1.com
14 TxHeader b X-Forwarded-For: 127.0.0.1
14 TxHeader b X-Varnish: 1405453128
14 TxHeader b Accept-Encoding: gzip
14 RxProtocol b HTTP/1.1
14 RxStatus b 404
14 RxResponse b Not Found
14 RxHeader b Date: Thu, 07 Nov 2013 17:07:50 GMT
14 RxHeader b Server: Apache/2.2.15 (Red Hat)
14 RxHeader b Content-Length: 295
14 RxHeader b Content-Type: text/html; charset=iso-8859-1
14 Fetch_Body b 4(length) cls 0 mklen 1
14 Length b 295
14 BackendReuse b default
12 SessionOpen c 127.0.0.1 48771 :6081
12 ReqStart c 127.0.0.1 48771 1405453128
12 RxRequest c GET
12 RxURL c /somedir?somevar=anothervar&andanother=123456
12 RxProtocol c HTTP/1.1
12 RxHeader c User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.13.1.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2
12 RxHeader c Accept: */*
12 RxHeader c Host: foo.example1.com
12 VCL_call c recv lookup
12 VCL_call c hash
12 Hash c /somedir?somevar=anothervar&andanother=123456
12 Hash c foo.example1.com
12 VCL_return c hash
12 VCL_call c miss fetch
12 Backend c 14 default default
12 TTL c 1405453128 RFC 120 -1 -1 1383844070 0 1383844070 0 0
12 VCL_call c fetch
12 TTL c 1405453128 VCL 5 -1 -1 1383844070 -0
12 VCL_return c deliver
12 ObjProtocol c HTTP/1.1
12 ObjResponse c Not Found
12 ObjHeader c Date: Thu, 07 Nov 2013 17:07:50 GMT
12 ObjHeader c Server: Apache/2.2.15 (Red Hat)
12 ObjHeader c Content-Type: text/html; charset=iso-8859-1
12 VCL_call c deliver deliver
12 TxProtocol c HTTP/1.1
12 TxStatus c 404
12 TxResponse c Not Found
12 TxHeader c Server: Apache/2.2.15 (Red Hat)
12 TxHeader c Content-Type: text/html; charset=iso-8859-1
12 TxHeader c Content-Length: 295
12 TxHeader c Accept-Ranges: bytes
12 TxHeader c Date: Thu, 07 Nov 2013 17:07:50 GMT
12 TxHeader c X-Varnish: 1405453128
12 TxHeader c Age: 0
12 TxHeader c Via: 1.1 varnish
12 TxHeader c Connection: keep-alive
12 Length c 295
12 ReqEnd c 1405453128 1383844070.464804649 1383844070.465569973 0.000082016 0.000713110 0.000052214
12 SessionClose c EOF
12 StatSess c 127.0.0.1 48771 0 1 1 0 0 1 257 295
最佳答案
此 Varnish 日志非常清楚。
您的后端使用404响应您所请求的URL。您将在后端访问日志中找到相同的返回码。
关于对于有效的 URL,Varnish 返回 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19843091/
我一生都找不到有关 Varnish (版本 3)对象可能属性的任何文档。 我们知道(从谷歌搜索中,varnish 文档只是咕哝,让你更加沮丧)例如,请求对象具有 url 属性(req.url),并且它
我们公司最近决定开始使用 Varnish HTTP 加速器。我们选择这个解决方案的最重要原因是因为我们是一家专门构建网络商店的公司 (Magento Enterprise) => Magento 有一
我们最近将Varnish放在了Drupal的前面,因为服务器承受着沉重的负担,总体而言,我们感到非常满意。 剩下的唯一问题是,有时我们在缓存的数据中会有一个无限的重定向循环。我们通过HTTP监控发现了
我正在设置连接到2个后端服务器(Magento 2应用程序)的Varnish 5实例。 我正在使用新的Varnish 5功能来加载多个VCL文件。为了使事情现在变得非常简单,我将在示例中使用1个后端服
我有一台 Vanilla 的Debian DigitalOcean机器,我正在尝试遵循《 Varnish 书》中的“开发人员”类(class)。我必须the first exercise, Insta
我已经为我的网站配置了Varnish,并且由于网站性能出色,但是没有人知道有任何Varnish监视工具可以查看Varnish中存储的内容以及与Memcached或APC监视工具类似的东西。 谢谢, -
我正在寻找 Varnish 高可用性设置的最佳设置。 具有多个 Varnish 实例的标准设置,每个实例都有自己的缓存存储,因此每个实例都在后端执行自己的请求。 即使使用 Varnish_Storag
我已经经历了这个 article 。有人可以帮我澄清以下有关 Varnish 各种日志位置的疑问吗? 根据 varnish 电子书 varnishncsa -显示 Varnish 访问日志和 varn
在不停机的情况下以编程方式向 Varnish director 添加或删除单个后端服务器的最佳方法是什么?我一直在寻找这方面的一个很好的例子,但找不到。 我希望能够根据需要扩展和缩减我的后端服务器。
我已经安装了 Apache 和 Tomcat,想在它们前面安装 Varnish,静态到 Apache,动态到 Tomcat(所有/static/* url 到 Apache,应该由 Varnish 缓
我目前正在做一个基于 Varnish 的项目。 我们写 vcl和 vmod .但是项目需要检查请求体。 如何在 VCL 中获取帖子请求正文或 vmod与 C function ? 最佳答案 你几乎可以
我习惯跑 varnishadm -T localhost:6082 debug.health 检查后端健康状态,但如何详细检查探测失败的原因(例如超时、错误的 http 状态代码)? 最佳答案 在 V
我正在尝试设置我的第一个 Varnish 缓存服务器,我有几个问题想问任何有经验的人。 1.) 我将 Varnish 作为独立服务器运行。我还需要在同一台服务器上安装 Apache 吗?最终,Varn
抱歉,我是 Varnish 的新手。 我正在我的 /etc/varnish/mysite.vlc 中尝试一堆东西,但无法让它工作。 我想将特定网址重定向到另一个网址。例子:如果有人访问 http://
我有这个: if (bereq.http.X-Path ~ "[a-z0-9]+\.(js|css)$") { set beresp.http.Cache-Control =
我想将Varnish用作“智能”代理,并且几乎可以正常工作。这个想法是,某些请求应通过Varnish传递,到达后端并返回,所有其他请求应返回“synt”消息,表明特定响应不包含任何结果。 这与Varn
我们将Varnish Cache用作许多客户的前端,并在任何后端出现问题时通过宽限期处理过时的内容。 我们现在确实有一个失败的后端,并且我们想增加宽限期(在生病的时候),这可能吗?我尝试在文档中进行挖
我们想要建立一个 Varnish 级联,以便我们进行1级和2级缓存。这意味着应要求 -1级 Varnish 的工艺和路线 -通往的 Varnish 等级2 - 应用 问题:如果应用程序现在在内容中添加
我在vcl中使用循环导演。我想查看所有缓存未命中URL和后端IP。现在在做sudo varnishtop -i BereqURL它只显示网址而不是后端IP的去向 54.42 BereqURL
是否可以设置 Varnish 以定期重建整个 field ?我在 Varnish 后面有一个播放应用程序。该应用程序生成了超过2,000页的网站号,其中大多数是产品页。是否可以将Varnish设置为从
我是一名优秀的程序员,十分优秀!