Upstream преждевременно закрыл соединение при чтении заголовка ответа от upstream, клиент: 192.168.208.1, сервер: localhost, запрос

Я пытаюсь развернуть свой проект Django в docker. к сожалению, я получаю ошибку 502 Bad Gateway, я перепробовал все, что смог найти в Интернете, но все та же ошибка.

Профиль Dockerfile:


FROM python:3.9-slim-buster

# create directory for the app user
ENV APP_HOME=/home/app/web


# create the app user
RUN addgroup --system app && adduser --system --group app

# create the appropriate directories
RUN mkdir -p $APP_HOME

# where the code lives
WORKDIR $APP_HOME

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1


# install  python dependencies
RUN apt-get update \
    && apt-get install -y build-essential python3-dev python2.7-dev \
    libldap2-dev libsasl2-dev libssl-dev ldap-utils tox \
    lcov valgrind \
    && apt-get -y install gcc \
    && apt install -y netcat

# install psycopg2 dependencies
RUN apt-get install -y postgresql-server-dev-all musl-dev



# copy project
COPY . $APP_HOME

# install dependencies
COPY ./requirements.txt $APP_HOME
RUN pip install --upgrade pip
RUN pip install -r $APP_HOME/requirements.txt

# copy entrypoint.sh
COPY ./entrypoint.sh $APP_HOME
RUN sed -i "s/\r$//g"  $APP_HOME/entrypoint.sh
RUN chmod +x  $APP_HOME/entrypoint.sh




# chown all the files to the app user
RUN chown -R app:app $APP_HOME 
RUN chmod -R 755 $APP_HOME 

# change to the app
USER app

# run entrypoint.sh
ENTRYPOINT ["/bin/bash","/home/app/web/entrypoint.sh"]

и docker-compose.yml

version: '3.9'


services:
  nginx:
    build: ./nginx
    links:
     - "web"
    ports:
      - "80:80"
    depends_on:
      - web
    restart: "on-failure"
  web:
    build: 
      context: .
    command: bash -c 'gunicorn --bind 0.0.0.0:8000 culture_crawler.wsgi'
    # command: bash -c " gunicorn culture_crawler.wsgi:application --bind 0.0.0.0:8000"
    volumes:
      - .:/culture_crawler:rw
    expose:
      - 8000
    env_file:
      - ./.env
    depends_on:
      - db
    restart: "on-failure"
  db:
    image: postgres:13-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    env_file:
      - ./.env.db
    restart: "on-failure"

volumes:
  postgres_data:

файл nginx.conf


upstream django {
    server web:8000;
}

server {

    listen 80;
    server_name  localhost;

    location / {
        proxy_read_timeout 300s;
        proxy_connect_timeout 300s;
        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;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_redirect off;
        proxy_pass http://django;
        
    }


    
}

и, наконец, докер-файл nginx

FROM nginx:1.21-alpine

RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d

Я не знаю, где я делаю неправильно. пожалуйста, помогите

Вернуться на верх