#configuration nginx docker with django

6 messages · Page 1 of 1 (latest)

obtuse glacier
#

So this is my docker compose

services:
  postgresql:
    container_name: postgresql
    image: postgres
    networks:
     
app-network
  env_file:
.env
restart: on-failure
ports:
5432:5432
volumes:
db_data:/backend/

  backend:
    container_name: django
    build: ./django
    depends_on:
      
postgresql
  networks: 
app-network
env_file: 
.env
restart: on-failure
ports: 
8000:8000
volumes :
backend_data:/backend/

  nginx:
    container_name: nginx
    build: ./nginx
    depends_on:
     
backend
  networks:
app-network
env_file: 
.env
restart: on-failure
ports:
443:443
volumes :
backend_data:/usr/share/nginx/html

networks:
  app-network:
    name: transcendance
    driver: bridge

volumes:
  backend_data:
    driver: local
    driver_opts: 
      type: none
      o: bind
      device: $PWD/django

  db_data:
#

and my script for django

sleep 5
echo "migrate"
python3 manage.py migrate

sleep 5
python3 manage.py collectstatic --noinput

sleep 5
gunicorn pong_game.wsgi:application --bind 0.0.0.0:8000
#

and my nginx.conf

server {
    listen 80;
    server_name localhost 127.0.0.1;

    # Redirection HTTP vers HTTPS
    return 301 https://$host$request_uri/;
}

server {
    listen 443 ssl;
    server_name localhost 127.0.0.1;

    ssl_certificate /etc/nginx/ssl/transcendance.crt;
    ssl_certificate_key /etc/nginx/ssl/transcendance.key;
    ssl_protocols TLSv1.2 TLSv1.3;

    location /static/ {
        alias /static/;
    }

    location / {
        try_files $uri $uri/ /index.html;
        proxy_pass http://127.0.0.1:8000/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    location = /favicon.ico {
        try_files $uri =404;
        access_log off;
        log_not_found off;
    }

    error_log /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
}
#

this is my first web project like this all it's new for me

#

So i don't where i can begin to debug