From e3930cf87a81f9f968c4847d1195c35486864f1b Mon Sep 17 00:00:00 2001 From: TheMaddax Date: Tue, 27 May 2025 12:54:13 -0500 Subject: [PATCH] Fix nginx logging configuration for statistics - Create log directory in Dockerfile - Add proper logging configuration to default.conf - Mount logs directory in docker-compose.yml for persistence - Fixes 502 error caused by missing log directory --- Dockerfile | 5 +++-- default.conf | 4 ++++ docker-compose.yml | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8408cb5..c9aa125 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,11 +18,12 @@ RUN pnpm build # Production image FROM nginx:alpine AS runner -# Create required directories +# Create required directories for web content and logs RUN mkdir -p /usr/share/nginx/html/images/thumbnails \ /usr/share/nginx/html/subtitles \ /usr/share/nginx/html/transcriptions \ - /usr/share/nginx/html/videos + /usr/share/nginx/html/videos \ + /var/log/nginx/deafgain-website # Copy built app and static assets COPY --from=builder /app/dist /usr/share/nginx/html diff --git a/default.conf b/default.conf index 2dcdf16..4a26e8b 100644 --- a/default.conf +++ b/default.conf @@ -4,6 +4,10 @@ server { root /usr/share/nginx/html; index index.html; + # Logging configuration for statistics + access_log /var/log/nginx/deafgain-website/access.log combined; + error_log /var/log/nginx/deafgain-website/error.log error; + # Security headers add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; diff --git a/docker-compose.yml b/docker-compose.yml index 55197a8..a075555 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,7 @@ services: restart: unless-stopped volumes: - /docker/websites/deafgain/video_content:/usr/share/nginx/html/videos + - /docker/websites/deafgain/logs:/var/log/nginx/deafgain-website networks: - caddy_network - default