gpt4 book ai didi

amazon-web-services - 亚马逊AWS + Varnish + varnish-devicedetect

转载 作者:行者123 更新时间:2023-12-03 17:46:07 25 4
gpt4 key购买 nike

有人可以帮忙设置吗?

在我的实例 (RHEL) 中,安装了 Varnish 效果很好。
然后设置 varnish-devicedetect

 yum  list installed | grep varnish
varnish.x86_64 3.0.5-1.16.amzn1 @amzn-main
varnish-libs.x86_64 3.0.5-1.16.amzn1 @amzn-main
varnish-release.noarch 4.0-3.el6 installed

当我尝试向 defaul.vcl 添加任何代码示例时,Varnish 无法启动。这段代码没问题:
 include "devicedetect.vcl";
sub vcl_recv {
call devicedetect;
}

但是在此 Varnish 无法启动之后:
 sub vcl_backend_response {
if (bereq.http.X-UA-Device) {
if (!beresp.http.Vary) { # no Vary at all
set beresp.http.Vary = "X-UA-Device";
} elsif (beresp.http.Vary !~ "X-UA-Device") { # add to existing Vary
set beresp.http.Vary = beresp.http.Vary + ", X-UA-Device";
}
}
# comment this out if you don't want the client to know your classification
set beresp.http.X-UA-Device = bereq.http.X-UA-Device;
}

尝试过,甚至是空的:
 sub vcl_backend_response {

}

导致同样的问题。
我错过了什么?

最佳答案

似乎找到了答案:需要使用Varnish ver。中的使用规则。 3,用过此套:

sub vcl_fetch {
if (req.http.X-UA-Device) {
if (!beresp.http.Vary) { # no Vary at all
set beresp.http.Vary = "X-UA-Device";
} elseif (beresp.http.Vary !~ "X-UA-Device") { # add to existing Vary
set beresp.http.Vary = beresp.http.Vary + ", X-UA-Device";
}
}
set beresp.http.X-UA-Device = req.http.X-UA-Device;
}
sub vcl_deliver {
if ((req.http.X-UA-Device) && (resp.http.Vary)) {
set resp.http.Vary = regsub(resp.http.Vary, "X-UA-Device", "User-Agent");
}
}

在这里找到: https://www.varnish-cache.org/docs/3.0/tutorial/devicedetection.html

关于amazon-web-services - 亚马逊AWS + Varnish + varnish-devicedetect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34086388/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com