【发布时间】:2014-06-28 20:38:53
【问题描述】:
仅当 url 不像“demo/secured”时才尝试删除 cookie
在 default.vcl 我有:
sub vcl_fetch {
# error 200 req.url ~ ".*/demo/secured/.*";
if (req.url ~ ".*/demo/secured/.*") {
set beresp.http.x-whaaat = "this is demo securd";
}else {
unset beresp.http.set-cookie;
set beresp.http.x-whaaat = "not demo secured";
}
}
带有或不带有 /demo/secured 的 URL 都会导致 x-whaaat 响应标头为“非演示安全”。但是取消注释错误 200 行会给带有 demo/secured 的 url 的错误 200 true 和没有 demo/secured 的 url 的错误 200 false。
我尝试了无数种 if 语句的变体,但无法让它返回除 false 之外的任何内容。
以下是正确的:
if ( "/app_dev.php/demo/secured/login" ~ ".*/demo/secured/.*" )
尽管我从error 200 req.url 的页面输出中复制并粘贴了“/app_dev.php/demo/secured/login”,但以下内容并不正确:
# error 200 req.url;
if ( req.url ~ ".*/demo/secured/.*" ) {
set beresp.http.x-whaaat = "this is demo securd";
}else {
unset beresp.http.set-cookie;
set beresp.http.x-whaaat = "not demo secured";
}
在http://site/app_dev.php/demo/secured/login 上给我一个“x-whaat not demo secure”标题,不确定这是怎么可能的,因为在取消注释错误 200 行时,相同的 url 给了我“/app_dev.php/demo/secured/login”。
varnishd -V
给我:
varnishd (varnish-3.0.5 revision 1a89b1f)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2011 Varnish Software AS
【问题讨论】:
标签: c boolean varnish varnish-vcl