![Varnish:vcl_error 重定向](https://linux22.com/image/623084/Varnish%EF%BC%9Avcl_error%20%E9%87%8D%E5%AE%9A%E5%90%91.png)
我有几个关于 Varnish 配置的问题。我有这个简单的配置文件:
backend default {
.host = "127.0.0.1";
.port = "80";
}
sub vcl_recv {
if (req.http.Host == "192.168.1.100")
{
set req.http.Location = "http://example.com" req.url;
error 750 "Permanently moved - TEST";
}
}
sub vcl_error {
if (obj.status == 750) {
set obj.http.Location = req.http.Location;
set obj.status = 301;
return(deliver);
}
}
问题:
(1)我已关注这例如:set req.http.Location = "http://example.com" + req.url;
- 但是,除非我删除这个符号,否则我无法重新加载 Varnish +
- 它是必需的吗?它的用途是什么?
# /etc/init.d/varnish reload
Loading vcl from /etc/varnish/default.vcl
Current running config name is reload_2013-12-17T15:01:43
Using new config name reload_2013-12-17T15:18:31
Message from VCC-compiler:
Expected variable, string or semicolon
(input Line 124 Pos 58)
set req.http.Location = "http://example.com" + req.url;
---------------------------------------------------------#---------
Running VCC-compiler failed, exit 1VCL compilation failed
Command failed with error code 106
varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082 vcl.load failed
答案1
在 2.1 中字符串连接如下所示:
set req.http.Location = "http://example.com" req.url;
在 3.0 中,这明确使用“+”完成。
https://www.varnish-cache.org/docs/3.0/installation/upgrade.html#string-concatenation-operator