Skip to content

Logrotate on nginx proxy manager is brokenΒ #4128

@theyo-tester

Description

@theyo-tester

βœ… Have you read and understood the above guidelines?

yes

πŸ“œ What is the name of the script you are using?

Nginx Proxy Manager

πŸ“‚ What was the exact command used to execute the script?

bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/nginxproxymanager.sh)"

βš™οΈ What settings are you using?

  • Default Settings
  • Advanced Settings

πŸ–₯️ Which Linux distribution are you using?

Debian/Proxmox 8.1.4

πŸ“ Provide a clear and concise description of the issue.

After months of running smoothly with default settings, the LXC container's npm 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. The default 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:

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 in the LXC. Instead nginx runs as root.

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 /run/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 /run/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

πŸ”„ Steps to reproduce the issue.

  1. Install Nginx Proxy Manager with the command bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/nginxproxymanager.sh)" and use default settings.
  2. Test the configuration (dry run): logrotate -d /etc/logrotate.d/nginx-proxy-manager
  3. Alternatively, check the content of /etc/logrotate.d/nginx-proxy-manager.

❌ Paste the full error output (if available).

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

πŸ–ΌοΈ Additional context (optional).

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions