[PR #3219] [MERGED] Make logrotate use the proper user and group. #3670

Closed
opened 2026-02-26 08:31:30 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/NginxProxyManager/nginx-proxy-manager/pull/3219
Author: @FibreTTP
Created: 9/27/2023
Status: Merged
Merged: 10/3/2023
Merged by: @jc21

Base: developHead: logrotate-perms


📝 Commits (3)

  • 6b565e6 Change perms on logrotated logs to npm user
  • 4867db0 Remove explicit user and group - add su directive for default user (npm).
  • f426e64 Add warning comment about changing the default user name and group name

📊 Changes

2 files changed (+8 additions, -2 deletions)

View changed files

📝 docker/rootfs/bin/common.sh (+4 -0)
📝 docker/rootfs/etc/logrotate.d/nginx-proxy-manager (+4 -2)

📄 Description

Fixes https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2938.

As seen in that issue, users are seeing an error when logrotate tries to own log files as root:

[9/24/2023] [6:11:02 PM] [Setup    ] › ⚠  warning   Error: Command failed: logrotate /etc/logrotate.d/nginx-proxy-manager
error: error setting owner of /data/logs/default-host_access.log to uid 0 and gid 0: Operation not permitted

where /data/logs/<anything> is the log failing to be owned. This causes logrotate to never be able to compress and delete logs.

Since the logrotate configuration was made before (the better) user and group configuration was implemented earlier this year, it was written to own the files as root.

This pull makes logrotate create the logs as whoever owned them beforehand by removing the explicit root user and group in the create directive. It also makes logrotate perform all actions as npm:npm, to ensure it doesn't regress https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1250.

It will also work when running as root, as when a PUID and PGID is not set, the npm:npm user/group will have the uid/gid of 0.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/NginxProxyManager/nginx-proxy-manager/pull/3219 **Author:** [@FibreTTP](https://github.com/FibreTTP) **Created:** 9/27/2023 **Status:** ✅ Merged **Merged:** 10/3/2023 **Merged by:** [@jc21](https://github.com/jc21) **Base:** `develop` ← **Head:** `logrotate-perms` --- ### 📝 Commits (3) - [`6b565e6`](https://github.com/NginxProxyManager/nginx-proxy-manager/commit/6b565e628f4c40e0050a2704c3dd56b4eaf9d184) Change perms on logrotated logs to npm user - [`4867db0`](https://github.com/NginxProxyManager/nginx-proxy-manager/commit/4867db078c9a7b606d42e0fe455e00561088bc71) Remove explicit user and group - add su directive for default user (npm). - [`f426e64`](https://github.com/NginxProxyManager/nginx-proxy-manager/commit/f426e6456935694b7a08ac139459ae136e4cc846) Add warning comment about changing the default user name and group name ### 📊 Changes **2 files changed** (+8 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docker/rootfs/bin/common.sh` (+4 -0) 📝 `docker/rootfs/etc/logrotate.d/nginx-proxy-manager` (+4 -2) </details> ### 📄 Description Fixes https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2938. As seen in that issue, users are seeing an error when logrotate tries to own log files as root: ``` [9/24/2023] [6:11:02 PM] [Setup ] › ⚠ warning Error: Command failed: logrotate /etc/logrotate.d/nginx-proxy-manager error: error setting owner of /data/logs/default-host_access.log to uid 0 and gid 0: Operation not permitted ``` where /data/logs/\<anything\> is the log failing to be owned. This causes logrotate to never be able to compress and delete logs. Since the logrotate configuration was made before (the better) user and group configuration was implemented earlier this year, it was written to own the files as root. This pull makes logrotate create the logs as whoever owned them beforehand by removing the explicit root user and group in the `create` directive. It also makes logrotate perform all actions as npm:npm, to ensure it doesn't regress https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1250. It will also work when running as root, as when a PUID and PGID is not set, the npm:npm user/group will have the uid/gid of 0. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 08:31:30 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-proxy-manager-NginxProxyManager#3670
No description provided.