core: configure log retention #86

Merged
rouven0 merged 1 commit from log-retention into main 2024-03-15 11:33:15 +01:00
2 changed files with 37 additions and 0 deletions
Showing only changes of commit 66a554a13b - Show all commits

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
}
'';
}