Docker uWSGI - NGINX:uWSGI 可以,但 NGINX 是 502

Docker uWSGI - NGINX: uWSGI ok but NGINX is a 502

我配置了我的 django-uwsgi-nginx 使用 docker 组合以下文件。

来自浏览器的“http://127.0.0.1:8000/”工作正常并为我提供了 django 默认页面

来自浏览器“http://127.0.0.1:80”抛出 502 Bad Gateway


dravoka-docker.conf

upstream web {
    server 0.0.0.0:8000;
}

server {
    listen 80;
    server_name web;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        alias "/dravoka-static/";
    }

    location / {
        include         uwsgi_params;
        proxy_pass      http://web;
    }
}

nginx/Dockerfile

FROM nginx:latest
RUN echo "---------------------- I AM NGINX --------------------------"
RUN rm /etc/nginx/conf.d/default.conf
ADD sites-enabled/ /etc/nginx/conf.d
RUN nginx -t

web 仅来自 "django-admin startproject web"

docker-compose.yaml

version: '3'

services:

  nginx:
    restart: always
    build: ./nginx/
    depends_on:
      - web
    ports:
      - "80:80"

  web:
    build: .
    image: dravoka-image
    ports:
      - "8000:8000"
    volumes:
      - .:/dravoka
    command: uwsgi /dravoka/web/dravoka.ini

Dockerfile

# Ubuntu base image
FROM ubuntu:latest
# Some installs........
EXPOSE 80

当您说来自 docker 实例时,您是 运行 从容器中卷曲的?或者您是 运行 来自本地的 curl 命令?

如果您是 运行 来自本地的,请将您的 docker-compose 的 web 服务更新为以下

...
  web:
    build: .
    image: dravoka-image
    expose:
      - "8000:8000"
    volumes:
      - .:/dravoka
    command: uwsgi /dravoka/web/dravoka.ini

然后重试。