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

问题描述 投票:0回答:1

我知道默认情况下没有启用Varnish日志记录并且它是通过varnishncsa启用的,有许多文章在线有关如何设置但不适用于Linux Alpine。我看到configurations for it here。但不确定任何日志记录服务默认运行。

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

varnish alpine
1个回答
1
投票

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

/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"]
© www.soinside.com 2019 - 2024. All rights reserved.