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

Problem with logrotate: Log rotation writes to incorrect file #3047

Open
gabinheylen opened this issue Jan 30, 2024 · 2 comments
Open

Problem with logrotate: Log rotation writes to incorrect file #3047

gabinheylen opened this issue Jan 30, 2024 · 2 comments
Labels
3.x Related to ModSecurity version 3.x

Comments

@gabinheylen
Copy link

gabinheylen commented Jan 30, 2024

Problem Description:

After configuring logrotate to handle ModSecurity log rotation, I encountered an unexpected issue. After the first rotation, logs are being written to the file modsec_audit.log.1 instead of modsec_audit.log. Additionally, all subsequent logs are appended to the modsec_audit.log.1 file, leading to potentially large log files.

Logrotate Configuration:

/var/log/modsec_audit.log {
  daily
  rotate 14
  compress
  delaycompress
  missingok
  notifempty
  create 644 root root
  sharedscripts
  postrotate
    /usr/sbin/service nginx reopenlogs >/dev/null 2>&1 || true
  endscript
}

Steps to Reproduce the Issue:

  1. ModSecurity configuration adhering to recommendations.
  2. Logrotate configuration added in /etc/logrotate.d/modsec.

Expected Behavior:

Logs should be correctly rotated into the modsec_audit.log file with the proper rotation suffix.

Observed Behavior:
Logs are written to the modsec_audit.log.1 file after the first rotation, and subsequent logs are appended to the modsec_audit.log.1 file.

Environment:

Operating System: linux ubuntu 20.04
ModSecurity Version: V3
Logrotate Version: 3.14.0

Your assistance in addressing this matter and providing guidance or a fix would be greatly appreciated. Thank you!

@airween
Copy link
Member

airween commented Jan 30, 2024

Hi @gabinheylen,

thank you for your report.

I'm really sorry to say but I'm afraid the problem that you're facing is a know problem, and unfortunately there is no solution yet. If I'm right, the issue #1968 discusses the issue. That references another issue under ModSecurity-nginx, namely #121. Please try to review it, may be you can find some help.

Please share your experiences with us.

@airween
Copy link
Member

airween commented Feb 29, 2024

@gabinheylen ping.

@airween airween added the 3.x Related to ModSecurity version 3.x label Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Related to ModSecurity version 3.x
Projects
None yet
Development

No branches or pull requests

2 participants