[GH-ISSUE #255] Add logrotate to docker container #5909

Closed
opened 2026-03-01 17:08:00 +03:00 by kerem · 8 comments
Owner

Originally created by @DjSni on GitHub (Jan 14, 2024).
Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/255

Originally assigned to: @0xJacky on GitHub.

Hello,

I have mounted the logs of nginx via a volume, because crouwdsec has to read them and I can also have a look from time to time even if the docker container is off.
I noticed that my logs have become almost 1GB in size in the meantime.
I think it would be good if the logrotate service is installed in the docker container.
Since nginx already provides the corresponding configs, nothing else needs to be set up.

Greetings

Originally created by @DjSni on GitHub (Jan 14, 2024). Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/255 Originally assigned to: @0xJacky on GitHub. Hello, I have mounted the logs of nginx via a volume, because crouwdsec has to read them and I can also have a look from time to time even if the docker container is off. I noticed that my logs have become almost 1GB in size in the meantime. I think it would be good if the logrotate service is installed in the docker container. Since nginx already provides the corresponding configs, nothing else needs to be set up. Greetings
kerem 2026-03-01 17:08:00 +03:00
Author
Owner

@jearton commented on GitHub (Feb 19, 2024):

The log rotation is already configured in the /etc/logrotate.d/nginx file within docker container.

image

Reference tutorial: https://www.digitalocean.com/community/tutorials/how-to-configure-logging-and-log-rotation-in-nginx-on-an-ubuntu-vps#log-rotation-with-logrotate

<!-- gh-comment-id:1952549060 --> @jearton commented on GitHub (Feb 19, 2024): The log rotation is already configured in the `/etc/logrotate.d/nginx` file within docker container. ![image](https://github.com/0xJacky/nginx-ui/assets/10370433/65d8ad57-f85d-4a83-8912-9694f0726d70) Reference tutorial: https://www.digitalocean.com/community/tutorials/how-to-configure-logging-and-log-rotation-in-nginx-on-an-ubuntu-vps#log-rotation-with-logrotate
Author
Owner

@DjSni commented on GitHub (Feb 19, 2024):

The log rotation is already configured in the /etc/logrotate.d/nginx file within docker container.

image

Reference tutorial: https://www.digitalocean.com/community/tutorials/how-to-configure-logging-and-log-rotation-in-nginx-on-an-ubuntu-vps#log-rotation-with-logrotate

But not installed.

<!-- gh-comment-id:1952554183 --> @DjSni commented on GitHub (Feb 19, 2024): > The log rotation is already configured in the `/etc/logrotate.d/nginx` file within docker container. > > ![image](https://private-user-images.githubusercontent.com/10370433/305979259-65d8ad57-f85d-4a83-8912-9694f0726d70.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDgzNTI4MTEsIm5iZiI6MTcwODM1MjUxMSwicGF0aCI6Ii8xMDM3MDQzMy8zMDU5NzkyNTktNjVkOGFkNTctZjg1ZC00YTgzLTg5MTItOTY5NGYwNzI2ZDcwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAyMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMjE5VDE0MjE1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRhMWNmNDAwZTQ1NzY5OWVjMzg4M2ZlMDc2YTIwNmY2OWM3NzUwZjQ1NTZkMzYzNGY4YWRlOGE5NWVmZTY4ZGMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0._NJmY3CwF6Qx23IiZAIn7hTy2sNwNDx7ppE7Xcb2y2o) > > Reference tutorial: https://www.digitalocean.com/community/tutorials/how-to-configure-logging-and-log-rotation-in-nginx-on-an-ubuntu-vps#log-rotation-with-logrotate But not installed.
Author
Owner

@jearton commented on GitHub (Feb 20, 2024):

I got it. So now we can only enter the container and install it.

apt update && apt install logrotate
<!-- gh-comment-id:1953399090 --> @jearton commented on GitHub (Feb 20, 2024): I got it. So now we can only enter the container and install it. ```bash apt update && apt install logrotate ```
Author
Owner

@DjSni commented on GitHub (Feb 20, 2024):

Ohh stupid, unfortunately it's not that easy since logrotate requires cron, this would also have to be installed.

This would only make the image unnecessarily larger, but 0xJacky could trigger it via the internal cron of nginx-ui, I just don't know how time-consuming that would be.

PS: it can be executed manually via logrotate /etc/logrotate.d/nginx.

<!-- gh-comment-id:1953420375 --> @DjSni commented on GitHub (Feb 20, 2024): Ohh stupid, unfortunately it's not that easy since logrotate requires cron, this would also have to be installed. This would only make the image unnecessarily larger, but 0xJacky could trigger it via the internal cron of nginx-ui, I just don't know how time-consuming that would be. PS: it can be executed manually via `logrotate /etc/logrotate.d/nginx`.
Author
Owner

@0xJacky commented on GitHub (Feb 20, 2024):

Ok, I plan to add this command into gocron, maybe later this week.

<!-- gh-comment-id:1953434726 --> @0xJacky commented on GitHub (Feb 20, 2024): Ok, I plan to add this command into gocron, maybe later this week.
Author
Owner

@DjSni commented on GitHub (Feb 20, 2024):

Ok, I plan to add this command into gocron, maybe later this week.

cool :) but don't forget you still have to install logrotate in the docker image.

<!-- gh-comment-id:1953436234 --> @DjSni commented on GitHub (Feb 20, 2024): > Ok, I plan to add this command into gocron, maybe later this week. cool :) but don't forget you still have to install logrotate in the docker image.
Author
Owner

@jearton commented on GitHub (Feb 20, 2024):

Recommended configuration about postrotate:

    postrotate
        /bin/kill -USR1 `cat /var/run/nginx.pid 2>/dev/null` 2>/dev/null || true
    endscript
<!-- gh-comment-id:1953894721 --> @jearton commented on GitHub (Feb 20, 2024): Recommended configuration about postrotate: ``` postrotate /bin/kill -USR1 `cat /var/run/nginx.pid 2>/dev/null` 2>/dev/null || true endscript ```
Author
Owner

@0xJacky commented on GitHub (Feb 25, 2024):

Hi,
This feature has been added in v2.0.0-beta.18, please note that you have to pull the lastest nginx-ui image from dockerhub, or you can maually install logrotate via apt in current container before upgrading nginx-ui.

If you find any problem about this feature, please reply to this issue, thanks.

<!-- gh-comment-id:1962931199 --> @0xJacky commented on GitHub (Feb 25, 2024): Hi, This feature has been added in v2.0.0-beta.18, please note that you have to pull the lastest nginx-ui image from dockerhub, or you can maually install logrotate via apt in current container before upgrading nginx-ui. If you find any problem about this feature, please reply to this issue, thanks.
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-ui#5909
No description provided.