如何在 Linux Alpine 上设置 Varnish 日志记录



我知道默认情况下不启用清漆日志记录,而是通过varnishncsa启用的,网上有很多关于如何设置它的文章,但没有使用 Linux Alpine。我在这里看到了它的配置。但不确定默认情况下是否运行任何日志记录服务。

任何帮助将不胜感激。非常感谢

要启用信息日志,您需要启动以下命令:

/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"]

最新更新