在我的 Varnish 2 设置中,我有一个像这样的清除/禁止块:
acl purge {
"localhost";
"x.x.x.x"/24;
}
sub vcl_recv {
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
return (lookup);
}
if (req.request == "BAN") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
ban("obj.http.x-host == " +req.http.host+" && obj.http.x-url ~ "+req.url);
# Throw a synthetic page so the
# request wont go to the backend.
error 200 "Ban added";
}
}
我希望我可以简单地替换client.ip
if 语句中的req.http.x-forwarded-for
,但是当我这样做时会发生以下编译错误:
Message from VCC-compiler:
Expected CSTR got 'purge'
(program line 944), at
('purging-banning.vcl' Line 16 Pos 41)
if (!req.http.x-forwarded-for ~ purge) {
----------------------------------------#####----
Running VCC-compiler failed, exit 1
VCL compilation failed
我一直在搜索 Google 和 StackOverflow,但我还没有找到一个很好的解决我的问题的方法,或者req.http.x-forwarded-for
这里没有找到正确位置的原因。
谁能帮忙?