簡體   English   中英

Nginx docker容器不接受容器中的燒瓶

[英]Nginx docker container not accepting and serving flask from container

因此,在過去的幾個小時中,我一直在努力解決這個問題,並且得到了一個docker-compose.yml文件

version: '2'

services:
  web:
    restart: always
    build: ./web_app
    expose:
      - "8000"
    ports:
      - "8000:8000"
    volumes:
      - ./web_app:/data/web
    command: /usr/local/bin/gunicorn web_interface:app -w 4 -t 90 --log-level=debug -b 0.0.0.0:8000 --reload
    depends_on:
      - postgres

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

  postgres:
    restart: always
    image: postgres:latest
    volumes_from:
      - data
    volumes:
      - ./postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
      - ./backups/postgresql:/backup
    expose:
      - "5432"

  data:
    restart: always
    image: alpine
    volumes:
      - /var/lib/postgresql
    tty: true

但是,當我docker-compose up然后導航到localhost:8880時,我什么也沒得到。 就像nginx服務器不接受通過本地主機的連接一樣。

nginx.conf

server {

    listen 80;
    server_name localhost;
    charset utf-8;

    location /static/ {
        alias /data/web/crm/web_interface;
    }

    location = /favicon.ico {
        alias /data/web/crm/web_interface/static/favicon.ico;
    }

    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;
    }

}

nginx / Dockerfile

FROM nginx:latest

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

COPY ./nginx.conf /etc/nginx/conf.d/nginx.conf 

這是我的終端機中的內容: 末梢射擊

我一直在密切關注教程,但它似乎無法滿足我創建的Flask應用程序的要求。 有任何想法嗎?

嘗試如下更改nginx服務的端口映射:

 ports:
  - "8880:80"

或讓nginx在端口8080上偵聽。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM