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

Add logrotate to docker container #255

Closed
DjSni opened this issue Jan 14, 2024 · 8 comments
Closed

Add logrotate to docker container #255

DjSni opened this issue Jan 14, 2024 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@DjSni
Copy link

DjSni commented Jan 14, 2024

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

@DjSni DjSni added the enhancement New feature or request label Jan 14, 2024
@jearton
Copy link

jearton commented 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

@DjSni
Copy link
Author

DjSni commented 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.

@jearton
Copy link

jearton commented Feb 20, 2024

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

apt update && apt install logrotate

@DjSni
Copy link
Author

DjSni commented 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.

@0xJacky
Copy link
Owner

0xJacky commented Feb 20, 2024

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

@0xJacky 0xJacky self-assigned this Feb 20, 2024
@DjSni
Copy link
Author

DjSni commented 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.

@jearton
Copy link

jearton commented Feb 20, 2024

Recommended configuration about postrotate:

    postrotate
        /bin/kill -USR1 `cat /var/run/nginx.pid 2>/dev/null` 2>/dev/null || true
    endscript

@0xJacky
Copy link
Owner

0xJacky commented 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.

@0xJacky 0xJacky closed this as completed Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants