0

我有一个简单的 VCL 文件如下:

vcl 4.0;

import std;

backend default {
    .host = "127.0.0.1";
    .port = "3333";
}

sub vcl_recv {
    std.log("req.host: "+req.host);
}

sub vcl_backend_response {

}

sub vcl_deliver {

}

当我尝试varnishd在我的 Mac 上使用此配置开始时,我收到以下错误:

Error:
Message from VCC-compiler:
Symbol not found: 'req.host' (expected type STRING):
('/Users/jononomo/dev/my_project/deploy/testing.vcl' Line 30 Pos 26)
    std.log("req.host: "+req.host);
-------------------------########--

('/Users/jononomo/dev/my_project/deploy/testing.vcl' Line 30 Pos 5) -- ('/Users/jononomo/dev/my_project/deploy/testing.vcl' Line 30 Pos 25)
    std.log("req.host: "+req.host);
----#####################----------

Running VCC-compiler failed, exited with 2
VCL compilation failed

我尝试了这条线的不同变体:

std.log("req.host: "+req.host);

如:

std.log(req.host: '+req.host);
std.log("req.host: ",req.host);
std.log('req.host: ',req.host);
std.log('hello');

但它们都不起作用。

如何从我的 VCL 文件中进行简单的日志记录?

谢谢。

更新: std.log("hello")似乎可以编译...但是,我需要记录有关请求对象的信息,并且req,request等不存在。

4

1 回答 1

1

改用req.http.host

vcl 4.0;

import std;

backend default {
    .host = "127.0.0.1";
    .port = "3333";
}

sub vcl_recv {
    std.log("req.host: " + req.http.host);
}

sub vcl_backend_response {

}

sub vcl_deliver {

}
于 2017-04-10T22:42:24.860 回答