Skip to content

Log rotate is broken (including easy fix) #4516

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

Open
theyo-tester opened this issue Apr 29, 2025 · 0 comments
Open

Log rotate is broken (including easy fix) #4516

theyo-tester opened this issue Apr 29, 2025 · 0 comments
Labels

Comments

@theyo-tester
Copy link

Checklist

  • Have you pulled and found the error with jc21/nginx-proxy-manager:latest docker image?
    • Yes
  • Are you sure you're not using someone else's docker image?
    • Yes
  • Have you searched for similar issues (both open and closed)?
    • Yes

Describe the bug

After months of running smoothly with default settings, the container suddenly stopped working properly. The Web UI showed "internal error" for any attempted changes.

Long story short, it turned out to be a storage issue. My storage limit of 4GB was full due to oversized log folders.

The du command returned:

...
769M    /var
341M   /root
1.6G    /data
...
1.6G    /data/logs
...
399M    /var/log
...
1.1G /data/logs/proxy-host-8_access.log

Root cause:

logrotate -d /etc/logrotate.d/nginx-proxy-manager returns:

reading config file /etc/logrotate.d/nginx-proxy-manager
error: /etc/logrotate.d/nginx-proxy-manager:2 unknown user 'npm'
error: found error in /data/logs/*_access.log /data/logs/*/access.log , skipping
removing last 1 log configs
error: /etc/logrotate.d/nginx-proxy-manager:16 unknown user 'npm'
error: found error in /data/logs/*_error.log /data/logs/*/error.log , skipping
removing last 1 log configs
Reading state from file: /var/lib/logrotate/status
Allocating hash table for state file, size 64 entries
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state

checking the logrotate configuration /etc/logrotate.d/nginx-proxy-manager:

cat /etc/logrotate.d/nginx-proxy-manager

/data/logs/*_access.log /data/logs/*/access.log {
    su npm npm
    create 0644
    weekly
    rotate 4
    missingok
    notifempty
    compress
    sharedscripts
    postrotate
    /bin/kill -USR1 `cat /run/nginx.pid 2>/dev/null` 2>/dev/null || true
    endscript
}

/data/logs/*_error.log /data/logs/*/error.log {
    su npm npm
    create 0644
    weekly
    rotate 10
    missingok
    notifempty
    compress
    sharedscripts
    postrotate
    /bin/kill -USR1 `cat /run/nginx.pid 2>/dev/null` 2>/dev/null || true
    endscript

Please note that the user npm does not exist. Instead nginx runs as root. Also, the PID-Path is wrong

FIX:

I suggest changing /etc/logrotate.d/nginx-proxy-manager to this:

/data/logs/*_access.log /data/logs/*/access.log {
    create 0644 root root
    weekly
    rotate 4
    missingok
    notifempty
    compress
    maxsize 100M
    maxage 365
    dateext
    sharedscripts
    postrotate
    /bin/kill -USR1 `cat /usr/local/openresty/nginx/logs/nginx.pid 2>/dev/null` 2>/dev/null || true
    endscript
}

/data/logs/*_error.log /data/logs/*/error.log {
    create 0644 root root
    weekly
    rotate 10
    missingok
    notifempty
    compress
    maxsize 50M
    maxage 365
    dateext
    sharedscripts
    postrotate
    /bin/kill -USR1 `cat /usr/local/openresty/nginx/logs/nginx.pid 2>/dev/null` 2>/dev/null || true
    endscript
}

Then run logrotate -v -f /etc/logrotate.d/nginx-proxy-manager
Optional for testing, run first logrotate -d /etc/logrotate.d/nginx-proxy-manager, to see what will happen.

The final result:
23M /data/logs

Nginx Proxy Manager Version

v2.11.1

To Reproduce
Steps to reproduce the behavior:

  1. logrotate -d /etc/logrotate.d/nginx-proxy-manager
  2. See error

Expected behavior

Logs in /data/logs should get rotated and compressed

Operating System
Proxmox, running as LXC
using release: https://api.github.com/repos/NginxProxyManager/nginx-proxy-manager/releases/latest

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant