From 459fe0930757e578c454def453fe8a7ded6fe555 Mon Sep 17 00:00:00 2001 From: godd0t Date: Wed, 10 May 2023 15:45:09 +0200 Subject: [PATCH] fix nginx media serve --- deployment/scripts/nginx/nginx.conf | 11 ++++------- docker-compose.prod.yml | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/deployment/scripts/nginx/nginx.conf b/deployment/scripts/nginx/nginx.conf index 19f9d17..9c246a3 100644 --- a/deployment/scripts/nginx/nginx.conf +++ b/deployment/scripts/nginx/nginx.conf @@ -3,17 +3,14 @@ events {} http { include /etc/nginx/mime.types; default_type application/octet-stream; + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; server { listen 80; - location /static { + location ~ ^/(images|javascript|js|css|flash|media|static)/ { autoindex on; - alias /usr/src/app/static/; - } - - location /media { - autoindex on; - alias /usr/src/app/media/; + alias /usr/src/app/; } } } diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index bbd6bbf..231fd6b 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -76,7 +76,7 @@ services: - media_files:/usr/src/app/media labels: - "traefik.enable=true" - - "traefik.http.routers.${APP_NAME}-nginx.rule=Host(`${APP_HOST}`) && (PathPrefix(`/static`) || PathPrefix(`/media`))" + - "traefik.http.routers.${APP_NAME}-nginx.rule=Host(`${APP_HOST}`) && (PathPrefix(`/static`) && PathPrefix(`/media`))" - "traefik.http.routers.${APP_NAME}-nginx.entrypoints=web" - "traefik.http.services.${APP_NAME}-nginx.loadbalancer.server.port=80" depends_on: