From d406c734ac727a3ede21be9e07044f54a0294b48 Mon Sep 17 00:00:00 2001 From: "alejandro.ayala" Date: Mon, 22 Jun 2026 10:20:21 -0500 Subject: [PATCH] feat: Nginx configurated to server images for catalog in production. --- docker-compose.prod.yml | 32 +++++++++++++++----------------- nginx.conf | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 nginx.conf diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index eaa2d27..cf8d80a 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -44,7 +44,7 @@ services: - media_volume:/app/media - logs_volume:/app/logs ports: - - "8000:8000" + - "127.0.0.1:9000:8000" depends_on: postgres: condition: service_healthy @@ -57,22 +57,20 @@ services: gunicorn config.wsgi:application --bind 0.0.0.0:8000 --workers 4 --timeout 120" # Optional: Nginx reverse proxy para servir archivos estáticos - # nginx: - # image: nginx:alpine - # container_name: tienda_ilusion_nginx - # ports: - # - "80:80" - # - "443:443" - # volumes: - # - ./nginx.conf:/etc/nginx/nginx.conf:ro - # - static_volume:/var/www/static:ro - # - media_volume:/var/www/media:ro - # - ./ssl:/etc/nginx/ssl:ro - # depends_on: - # - django - # networks: - # - tienda_network - # restart: unless-stopped + nginx: + image: nginx:alpine + ports: + - "10297:80" + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf:ro + - static_volume:/var/www/static + - media_volume:/var/www/media + - ./dist:/var/www/donconfiao + depends_on: + - django + networks: + - tienda_network + restart: unless-stopped volumes: postgres_data: diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..8c06a87 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,36 @@ +events { + worker_connections 1024; +} + +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; + server_name _; + client_max_body_size 10M; + + location /media/ { + alias /var/www/media/; + expires 30d; + add_header Cache-Control "public, immutable"; + } + + location /static/ { + alias /var/www/static/; + expires 365d; + add_header Cache-Control "public, immutable"; + } + + location / { + root /var/www/donconfiao/; + try_files $uri /index.html; + expires -1; + add_header Cache-Control "no-cache"; + } + } +}