Skip to content

🛡️ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!

Fix #211: nginx error log grew unbounded (3GB/month)

Omega (QA)1a115bf02501
diff --git a/Docker/logrotate-nginx b/Docker/logrotate-nginx
new file mode 100644
index 0000000..b902b65
--- /dev/null
+++ b/Docker/logrotate-nginx
@@ -0,0 +1,17 @@
+/var/log/nginx/*.log {
+ weekly
+ rotate 4
+ compress
+ delaycompress
+ missingok
+ notifempty
+ size 50M
+ create 0644 warracker warracker
+ sharedscripts
+ postrotate
+ # Reopen nginx log files after rotation
+ if [ -f /run/nginx.pid ]; then
+ kill -USR1 $(cat /run/nginx.pid)
+ fi
+ endscript
+}
diff --git a/Docker/supervisord.conf b/Docker/supervisord.conf
index 882d7b3..24f3961 100644
--- a/Docker/supervisord.conf
+++ b/Docker/supervisord.conf
@@ -36,3 +36,16 @@ stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
+
+[program:cron]
+command=/usr/sbin/cron -f
+user=root
+autostart=true
+autorestart=true
+startsecs=5
+startretries=5
+priority=30
+stdout_logfile=/dev/stdout
+stdout_logfile_maxbytes=0
+stderr_logfile=/dev/stderr
+stderr_logfile_maxbytes=0
diff --git a/Dockerfile b/Dockerfile
index 6fab8a9..46a4c7d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -32,6 +32,8 @@ RUN apt-get update && \
apt-get install -y --no-install-recommends \
nginx \
supervisor \
+ logrotate \
+ cron \
postgresql-client \
gettext-base \
curl \
@@ -79,6 +81,7 @@ COPY --chown=warracker:warracker backend/app.py backend/gunicorn_config.py ./
# Copy configuration files and scripts from Docker directory
COPY --chown=root:root Docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
+COPY --chown=root:root Docker/logrotate-nginx /etc/logrotate.d/nginx-warracker
COPY --chown=warracker:warracker Docker/entrypoint.sh /app/entrypoint.sh
COPY --chown=root:root Docker/nginx-wrapper.sh /app/nginx-wrapper.sh
diff --git a/nginx.conf b/nginx.conf
index 4feb90d..28aced9 100644
--- a/nginx.conf
+++ b/nginx.conf
@@ -7,7 +7,7 @@ server {
index index.html;
# Enable detailed error logging
- error_log /var/log/nginx/error.log debug;
+ error_log /var/log/nginx/error.log warn;
access_log /var/log/nginx/access.log;
# Global settings