【发布时间】:2021-05-12 18:40:24
【问题描述】:
我想知道 varnish 和标头 vmod 的意外行为。
由于header.copy 在vcl_deliver 中的使用,以下vcl 将无法编译。
为什么这里不允许使用header.copy?有没有关于这种行为的文档? varnish 的文档和标题都没有说明任何内容。
我不需要解决方法。我已经有了。
vcl 4.1;
import header;
backend default {
.host = "127.0.0.1";
.port = "8888";
}
sub vcl_backend_response {
header.copy(beresp.http.Set-Cookie, beresp.http.X-Set-Cookie);
unset beresp.http.Set-Cookie;
}
sub vcl_deliver {
header.copy(beresp.http.X-Set-Cookie, beresp.http.Set-Cookie);
unset beresp.http.X-Set-Cookie;
}
编译时会出现如下错误
2 月 9 日 06:40:11 epcentos7.dev varnishd[12938]:错误:2 月 9 日 06:40:11
epcentos7.dev varnishd[12938]:来自 VCC 编译器的消息:2 月 9 日
06:40:11 epcentos7.dev varnishd[12938]: ('/etc/varnish/default.vcl'
第 15 行,第 15 行)-(第 20 行)2 月 9 日 06:40:11 epcentos7.dev
varnishd[12938]: header.copy(beresp.http.X-Set-Cookie,
beresp.http.Set-Cookie); 2 月 9 日 06:40:11 epcentos7.dev
清漆[12938]:
--------------######------------------------------ --------------
2 月 9 日 06:40:11 epcentos7.dev varnishd[12938]:在子程序中不可用
'vcl_deliver'。 2 月 9 日 06:40:11 epcentos7.dev varnishd[12938]:运行
VCC 编译器失败,退出 2 Feb 09 06:40:11 epcentos7.dev
varnishd[12938]:VCL 编译失败 2 月 9 日 06:40:11 epcentos7.dev
systemd[1]: varnish.service: 控制进程退出,code=exited
status=255 Feb 09 06:40:11 epcentos7.dev systemd[1]: 启动失败
Varnish Cache,一种高性能的 HTTP 加速器。
【问题讨论】:
标签: varnish varnish-vcl