django+;uwsgi&x2B;连接到上游时的docker

django+;uwsgi&x2B;连接到上游时的docker,django,docker,nginx,uwsgi,Django,Docker,Nginx,Uwsgi,我通过docker制作了基础设施 要部署django,请使用uwsgi和nginx 这是我的配置文件 [docker compose.yml] version: '3.7' services: nginx: build: context: . dockerfile: docker/nginx/Dockerfile container_name: nginx hostname: nginx ports: - '80:80'

我通过docker制作了基础设施

要部署django,请使用uwsgi和nginx

这是我的配置文件

[docker compose.yml]

version: '3.7'

services:
  nginx:
    build:
      context: .
      dockerfile: docker/nginx/Dockerfile
    container_name: nginx
    hostname: nginx
    ports:
      - '80:80'
    networks:
      - backend
    restart: on-failure
    links:
      - web_service
    depends_on:
      - web_service

  web_service:
    build:
      context: .
      dockerfile: docker/web-dev/Dockerfile
    container_name: web_service
    hostname: web_service
    ports:
      - '8000:8000'
    networks:
      - backend
    tty: true
    volumes:
      - $PWD:/home

networks:
  backend:
    driver: 'bridge'
[docker/web dev/Dockerfile]

FROM python:3.6.5

COPY Pipfile ./home
COPY Pipfile.lock ./home
WORKDIR /home
RUN pip3 install pipenv
RUN pipenv install --system
RUN apt-get update && apt-get install -y vim && apt-get install -y git
RUN pip3 install uwsgi && pip3 install git+https://github.com/Supervisor/supervisor
CMD ["uwsgi", "--ini", "docker/config/uwsgi.ini"]
FROM nginx:latest

COPY . ./home
WORKDIR home
RUN rm /etc/nginx/conf.d/default.conf
COPY ./docker/config/nginx.conf /etc/nginx/conf.d/default.conf
[docker/nginx/Dockerfile]

FROM python:3.6.5

COPY Pipfile ./home
COPY Pipfile.lock ./home
WORKDIR /home
RUN pip3 install pipenv
RUN pipenv install --system
RUN apt-get update && apt-get install -y vim && apt-get install -y git
RUN pip3 install uwsgi && pip3 install git+https://github.com/Supervisor/supervisor
CMD ["uwsgi", "--ini", "docker/config/uwsgi.ini"]
FROM nginx:latest

COPY . ./home
WORKDIR home
RUN rm /etc/nginx/conf.d/default.conf
COPY ./docker/config/nginx.conf /etc/nginx/conf.d/default.conf
[nginx.conf]

upstream django {
    server web_service:8001;
}
server {
    listen 80;
    server_name 127.0.0.1;
    charset utf-8;

    location / {
        uwsgi_pass django;
        include /etc/nginx/uwsgi_params;
    }

    location /media {
        alias /home/example/media;
    }

    location /static {
        alias /home/example/static;
    }
}
[uwsgi.ini]

[uwsgi]

chdir = /home
module = example.wsgi:application
master = true
process = %(%k * 3)
socket = 127.0.0.1:8001
vaccum = true
chmod-socket=664
我将nginx“/”设置为django,django正在通过端口8000进行监听

此外,uwsgi正在通过8001监听,并连接nginx和django

但是当我连接到
http://localhost
,它会引发上行错误

web浏览器->502坏网关中显示错误

docker日志中显示错误->

连接到上游时,
connect()失败(111:连接被拒绝),客户端:172.31.0.1,服务器:127.0.0.1,请求:“GET/HTTP/1.1”,上游:uwsgi://172.31.0.3:8001,主机:“localhost”

我在谷歌上搜索了几个小时,但没有找到任何方法

这里有什么解决办法吗

谢谢