【问题标题】:Error 502 Bad Gateway Nginx and Celery Workers错误 502 Bad Gateway Nginx 和 Celery Workers
【发布时间】:2017-03-24 13:31:48
【问题描述】:

我正在尝试在 Gunicorn 服务器中使用 Nginx、Celery、RabbitMQ 和 Django 运行 docker-compose。应用程序在没有 Nginx 的情况下运行良好,但在生产中我需要 Nginx 来提供静态文件,并在添加时从 Nginx 获得Error 502 Bad Gateway

下面是 docker-compose:

version: "2"
services:
  web:
    build: ./web
    expose:
      - "8000"
    depends_on:
      - redis
      - postgres
      - rabbit
    volumes:
        - .:/app
    env_file: .env
    environment:
      DEBUG: 'true'
    command: /usr/local/bin/gunicorn api.wsgi:application -w 2 -b :8000

  nginx:
    build: ./nginx/
    ports:
      - "80:80"
    volumes:
      - /www/static
    volumes_from:
      - web

  rabbit:
    hostname: rabbit
    image: rabbitmq:latest
    environment:
        - RABBITMQ_DEFAULT_USER=admin
        - RABBITMQ_DEFAULT_PASS=mypass
    ports:
        - "5672:5672"
        - "15672:15672"

  postgres:
    image: postgres:latest
    volumes:
      - db-data:/var/lib/postgresql/data

  redis:
    image: redis:latest


volumes:
  db-data:

下面是我的 Nginx.conf 文件:

server {

    listen 80;
    server_name example.org;
    charset utf-8;

    location /static {
        alias /usr/src/app/static;
    }

    location / {
        proxy_pass http://web: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;
    }

}

有谁知道可能导致问题的原因?在 stackoverflow 上报告的大多数问题都不处理 celery 工作人员面前的代理服务器

【问题讨论】:

    标签: nginx celery docker-compose gunicorn


    【解决方案1】:

    问题是我必须指定所有 css 文件的位置,并在 docker-compose.yml 文件中指定我的 docker 卷。之后,一切都很顺利。比较琐碎

    【讨论】:

      猜你喜欢
      • 2018-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-12
      • 2019-09-05
      • 1970-01-01
      • 2016-09-14
      • 2019-09-15
      相关资源
      最近更新 更多