Merge pull request #86 from fsr/log-retention

core: configure log retention
This commit is contained in:
Rouven Seifert 2024-03-15 11:33:15 +01:00 committed by GitHub
commit 1e689b6c40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 0 deletions

View file

@ -2,6 +2,7 @@
{ {
imports = [ imports = [
./base.nix ./base.nix
./logging.nix
./bacula.nix ./bacula.nix
./fail2ban.nix ./fail2ban.nix
./initrd-ssh.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
}
'';
}