mirror of
https://github.com/GrapheneOS/infrastructure.git
synced 2025-11-18 06:01:28 -05:00
set up syslog-ng for nginx access log
This sets up the infrastructure for moving from storing nginx access logs in journald to plain text files written by syslog-ng and rotated by logrotate. This works around the poor performance, poor space efficiency and lack of archived log compression for journald. Unlike writing access logs directly with nginx, this continues avoiding blocking writes in the event loop and sticks to asynchronous sends through a socket. Since nginx only supports syslog via the RFC 3164 protocol rather than the more modern RFC 5424 protocol, this leaves formatting timestamps up to nginx rather than using the ones provided via the syslog protocol.
This commit is contained in:
parent
97d55a130e
commit
2caa67529a
31 changed files with 81 additions and 1 deletions
|
|
@ -15,10 +15,13 @@ for host in ${hosts_web[@]}; do
|
|||
rsync etc/systemd/system/{session-ticket-keys-create.service,session-ticket-keys-rotate.service,session-ticket-keys-rotate.timer} $remote:/etc/systemd/system/
|
||||
rsync --chmod=755 session-ticket-keys-create session-ticket-keys-rotate $remote:/usr/local/bin/
|
||||
rsync -r --delete etc/systemd/system/nginx.service.d/ $remote:/etc/systemd/system/nginx.service.d
|
||||
rsync etc/syslog-ng/syslog-ng.conf $remote:/etc/syslog-ng/syslog-ng.conf
|
||||
rsync etc/logrotate.d/nginx $remote:/etc/logrotate.d/nginx
|
||||
|
||||
ssh $remote "mkdir -pm755 /var/cache/nginx
|
||||
groupadd -fg 2100 tls
|
||||
mkdir -p -m 750 /etc/session-ticket-keys && chgrp tls /etc/session-ticket-keys
|
||||
systemctl daemon-reload &&
|
||||
systemctl enable --now session-ticket-keys-create.service session-ticket-keys-rotate.timer nginx.service"
|
||||
systemctl enable --now session-ticket-keys-create.service session-ticket-keys-rotate.timer syslog-ng@default.service nginx.service
|
||||
syslog-ng-ctl reload"
|
||||
done
|
||||
|
|
|
|||
11
etc/logrotate.d/nginx
Normal file
11
etc/logrotate.d/nginx
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/var/log/nginx/*log {
|
||||
missingok
|
||||
notifempty
|
||||
create 600 root root
|
||||
sharedscripts
|
||||
compress
|
||||
maxsize 2G
|
||||
postrotate
|
||||
syslog-ng-ctl reopen >/dev/null
|
||||
endscript
|
||||
}
|
||||
30
etc/syslog-ng/syslog-ng.conf
Normal file
30
etc/syslog-ng/syslog-ng.conf
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
@version: 4.10
|
||||
|
||||
source s_internal {
|
||||
internal();
|
||||
};
|
||||
source s_nginx_access_log {
|
||||
unix-dgram("/run/nginx-access-log" group("http") perm(0660));
|
||||
};
|
||||
|
||||
destination d_journald {
|
||||
unix-dgram("/dev/log");
|
||||
};
|
||||
destination d_nginx {
|
||||
file("/var/log/nginx/access.log" template("${MESSAGE}\n"));
|
||||
};
|
||||
|
||||
log {
|
||||
source(s_internal);
|
||||
destination(d_journald);
|
||||
};
|
||||
log {
|
||||
source(s_nginx_access_log);
|
||||
destination(d_nginx);
|
||||
};
|
||||
|
||||
options {
|
||||
keep-hostname(yes);
|
||||
stats(freq(0));
|
||||
use-dns(no);
|
||||
};
|
||||
7
etc/systemd/system/logrotate.timer.d/override.conf
Normal file
7
etc/systemd/system/logrotate.timer.d/override.conf
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[Unit]
|
||||
Description=Rotate log files every 5 minutes
|
||||
|
||||
[Timer]
|
||||
AccuracySec=1us
|
||||
OnCalendar=*:0/5
|
||||
RandomizedDelaySec=0
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
[Unit]
|
||||
After=syslog-ng.service
|
||||
|
||||
[Service]
|
||||
CapabilityBoundingSet=CAP_CHOWN CAP_DAC_OVERRIDE CAP_NET_BIND_SERVICE CAP_SETUID CAP_SETGID
|
||||
LockPersonality=true
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ rsync
|
|||
smartmontools
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ rsync
|
|||
smartmontools
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ rsync
|
|||
smartmontools
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ rsync
|
|||
sqlite-analyzer
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ python-swiftclient
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ python-swiftclient
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ rsync
|
|||
s-nail
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ python-swiftclient
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ rsync
|
|||
sqlite-analyzer
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ pv
|
|||
rsync
|
||||
strace
|
||||
stress
|
||||
syslog-ng
|
||||
sysstat
|
||||
tinyxxd
|
||||
tree
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue