我的配置基于 Varnish 3.0,我一直在更新它们。但我遇到了障碍。
vcl_fetch
已替换为 vcl_backend_response
。在 vcl_fetch
内部,您过去可以使用 req.url
,但在 vcl_backend_response
内部不再可以使用。
所以我留下了三个不起作用的 if
语句:
sub vcl_backend_response {
set beresp.do_esi = true;
if (!(req.url ~ "wp-(login|admin)")) {
unset beresp.http.set-cookie;
}
if ( req.http.host ~ "[0-9]\.example\.com" || req.http.host ~ "[0-9]\.example\.com") {
set beresp.ttl = 60s;
}
if ( req.url ~ "\.(html|htm|css|js|txt|xml|svg)(\?[a-z0-9=]+)?$" ) {
set beresp.do_gzip = true;
}
}
如何在 Varnish 4.0 版中转换这些配置?
顺便说一下,我是 Varnish VCL 的新手。
最佳答案
您现在必须在 vcl_backend_response
中使用 bereq.url
。
关于varnish - 如何获取 vcl_backend_response 中的 req.url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27195918/