core: configure log retention

This commit is contained in:
Rouven Seifert 2024-03-14 23:59:42 +01:00
parent d1c2ece3ea
commit 66a554a13b
Signed by: rouven.seifert
GPG key ID: B95E8FE6B11C4D09
2 changed files with 37 additions and 0 deletions

View file

@ -2,6 +2,7 @@
{
imports = [
./base.nix
./logging.nix
./bacula.nix
./fail2ban.nix
./initrd-ssh.nix

36
modules/core/logging.nix Normal file
View file

@ -0,0 +1,36 @@
{ pkgs, ... }:
{
services.rsyslogd = {
enable = true;
defaultConfig = ''
:programname, isequal, "postfix" /var/log/postfix.log
auth.* -/var/log/auth.log
'';
};
services.logrotate.configFile = pkgs.writeText "logrotate.conf" ''
weekly
missingok
notifempty
rotate 4
"/var/log/postfix.log" {
compress
delaycompress
weekly
rotate 156
dateext
dateformat .%Y-%m-%d
extension log
}
"/var/log/nginx/*.log" {
compress
delaycompress
weekly
postrotate
[ ! -f /var/run/nginx/nginx.pid ] || kill -USR1 `cat /var/run/nginx/nginx.pid`
endscript
rotate 26
su nginx nginx
}
'';
}