Add syslog logging for varnish
This commit is contained in:
parent
66d863906e
commit
bdde0ee03a
|
@ -13,6 +13,9 @@ RUN chmod +x /start ;\
|
|||
rm /etc/varnish/secret
|
||||
|
||||
ADD varnish.conf /etc/supervisor/conf.d/varnish.conf
|
||||
ADD varnishlogger.conf /etc/supervisor/conf.d/varnishlogger.conf
|
||||
ADD varnishlog.conf /etc/rsyslog.d/varnishlog.conf
|
||||
ADD rsyslogd.conf /etc/supervisor/conf.d/rsyslogd.conf
|
||||
ADD supervisor.conf /etc/supervisor/conf.d/supervisor.conf
|
||||
|
||||
WORKDIR /etc/varnish
|
||||
|
|
|
@ -17,3 +17,5 @@ Container for running [Varnish Cache](https://www.varnish-cache.org/). Automatic
|
|||
*Extras*
|
||||
|
||||
* test.vcl - example default.vcl file
|
||||
* monitorvcl - example showing how reload varnish when the vcl is modified
|
||||
* Apache-format logs are sent to the docker host with rsyslog with programname 'varnish', channel local6.notice
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Wait for the vcl to be modified then tell varnish to reload
|
||||
while inotifywait -qq --event modify /etc/varnish/default.vcl; do
|
||||
pkill -HUP varnishd
|
||||
done
|
|
@ -0,0 +1,2 @@
|
|||
[program:rsyslog]
|
||||
command=rsyslogd -n
|
11
start
11
start
|
@ -3,18 +3,27 @@
|
|||
# Cleanly kill supervisor when container is stopped
|
||||
trap 'kill $(jobs -p)' EXIT
|
||||
|
||||
# Set default varnish memory cache size if not specified
|
||||
if [ -z "$MEMSIZE" ]; then
|
||||
export MEMSIZE=64M
|
||||
fi
|
||||
|
||||
# Set varnish secret if not specified
|
||||
if [ ! -f /etc/varnish/secret ]; then
|
||||
if [ -z "$SECRET" ]; then
|
||||
SECRET=`cat /proc/sys/kernel/random/uuid`
|
||||
fi
|
||||
echo $SECRET > /etc/varnish/secret
|
||||
fi
|
||||
echo "Secret is $SECRET"
|
||||
|
||||
echo "Secret is `cat /etc/varnish/secret`"
|
||||
# Set access syslog host if not specified
|
||||
if [ -z "$LOGHOST" ]; then
|
||||
LOGHOST=`ip route | grep default | awk '{print $3}'`
|
||||
fi
|
||||
sed -i -E "s/@.+/@$LOGHOST/" /etc/rsyslog.d/varnishlog.conf
|
||||
|
||||
# Check vcl syntax
|
||||
varnishd -C -f /etc/varnish/default.vcl > /dev/null || exit 1
|
||||
|
||||
supervisord
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
if $programname == 'varnish' then @172.17.42.1
|
||||
& ~
|
|
@ -0,0 +1,5 @@
|
|||
[program:varnishlogger]
|
||||
command=bash -c "varnishncsa -F '%%{X-Real-IP}i %%l %%u %%t \"%%r\" %%s %%b \"%%{Referer}i\" \"%%{User-agent}i\"' | /usr/bin/logger -tvarnish -plocal6.notice"
|
||||
autostart=true
|
||||
autorestart=true
|
||||
redirect_stderr=true
|
Loading…
Reference in New Issue