我知道默认情况下没有启用Varnish日志记录并且它是通过varnishncsa
启用的,有许多文章在线有关如何设置但不适用于Linux Alpine。我看到configurations for it here。但不确定任何日志记录服务默认运行。
任何帮助将非常感激。非常感谢
要启用信息日志,您需要启动以下命令:
/usr/bin/varnishncsa -q 'ReqURL ne "<url_which_should_be_not_logged>"' -F '%{Host}i %h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\" \"%{Varnish:hitmiss}x\"' -w /path/to/log_file
在varnishd
开始之后:
/usr/sbin/varnishd -s malloc,128M -a :80 -f /etc/varnish/default.vcl
如果我们在谈论Docker容器中的Alpine,只需创建以下entrypoint.sh
脚本:
#!/bin/bash
mkdir -p /var/lib/varnish/`hostname` && chown nobody /var/lib/varnish/`hostname`
/usr/sbin/varnishd -s malloc,128M -a :80 -f /etc/varnish/default.vcl
/usr/bin/varnishncsa -q 'ReqURL ne "<url_which_should_be_not_logged>"' -F '%{Host}i %h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\" \"%{Varnish:hitmiss}x\"'
并将它放在Dockerfile
的末尾:
ENTRYPOINT ["/entrypoint.sh"]