fix:#52 added log rotation and anonymized

This commit is contained in:
Elmar Kresse
2024-09-29 23:33:45 +02:00
parent 5ce70983f2
commit f3bfe603b3
5 changed files with 29 additions and 4 deletions

View File

@ -40,8 +40,8 @@ services:
build: build:
dockerfile: Dockerfile dockerfile: Dockerfile
context: ./frontend context: ./frontend
target: dev target: prod
command: "npm run dev" #command: "npm run dev"
# open port 8000 # open port 8000
ports: ports:
- "8000:8000" - "8000:8000"

View File

@ -35,8 +35,13 @@ COPY . ./
# https://hub.docker.com/r/bitnami/nginx -> always run as non-root user # https://hub.docker.com/r/bitnami/nginx -> always run as non-root user
FROM bitnami/nginx:1.25 AS prod FROM bitnami/nginx:1.25 AS prod
USER root
RUN install_packages logrotate
USER 1001
# copy build files from build container # copy build files from build container
COPY --from=build /app/dist /app COPY --from=build /app/dist /app
COPY ./nginx.conf /opt/bitnami/nginx/conf/nginx.conf COPY ./nginx.conf /opt/bitnami/nginx/conf/nginx.conf
COPY nginx-logrotate /etc/logrotate.d/nginx
EXPOSE 8000 EXPOSE 8000

14
frontend/nginx-logrotate Normal file
View File

@ -0,0 +1,14 @@
/opt/bitnami/nginx/logs/proxy_*.log {
rotate 5
daily
notifempty
compress
delaycompress
create 0640 root root
sharedscripts
postrotate
# Reload NGINX to reopen the log files after rotation
[ -f /opt/bitnami/nginx/tmp/nginx.pid ] && kill -USR1 `cat /opt/bitnami/nginx/tmp/nginx.pid`
endscript
}

View File

@ -27,7 +27,10 @@ http {
include mime.types; include mime.types;
default_type application/octet-stream; default_type application/octet-stream;
access_log /opt/bitnami/nginx/logs/proxy_access.log; # Define a custom log format for anonymizing logs
log_format anonymized '[$time_local] "$request" $status $body_bytes_sent "$http_referer"';
access_log /opt/bitnami/nginx/logs/proxy_access.log anonymized;
error_log /opt/bitnami/nginx/logs/proxy_error.log; error_log /opt/bitnami/nginx/logs/proxy_error.log;
sendfile on; sendfile on;

View File

@ -59,7 +59,10 @@ http {
real_ip_header CF-Connecting-IP; real_ip_header CF-Connecting-IP;
access_log /opt/bitnami/nginx/logs/proxy_access.log; # Define a custom log format for anonymizing logs
log_format anonymized '[$time_local] "$request" $status $body_bytes_sent "$http_referer"';
access_log /opt/bitnami/nginx/logs/proxy_access.log anonymized;
error_log /opt/bitnami/nginx/logs/proxy_error.log; error_log /opt/bitnami/nginx/logs/proxy_error.log;
sendfile on; sendfile on;