Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx: use copytruncate for modsecurity log rotation #957

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions nixos/services/nginx/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -469,16 +469,27 @@ in
inherit virtualHosts;
};

services.logrotate.settings = {
"/var/log/nginx/*.log" = {
services.logrotate.settings = let
commonRotate = {
rotate = cfg.rotateLogs;
create = "0644 ${nginxCfg.masterUser} nginx";
su = "${nginxCfg.masterUser} nginx";
};
in {
"/var/log/nginx/modsec_*.log" = {
# need higher prio, because more-specific match.
# Our platform header options use priority 900, we need to chose a
# higher number here for using them.
ignoreduplicates = true;
priority = 901;
copytruncate = true;
} // commonRotate;
"/var/log/nginx/*.log" = {
postrotate = ''
systemctl kill nginx -s USR1 --kill-who=main || systemctl reload nginx
chown ${nginxCfg.masterUser}:nginx /var/log/nginx/*
'';
};
} // commonRotate;
};

# Z: Recursively change permissions if they already exist.
Expand Down
Loading