通过nginx和gunicorn在d中提供Flask

2024-05-19 01:36:41 发布

您现在位置:Python中文网/ 问答频道 /正文

玩烧瓶我想得到一个真正的设置和运行在码头。这意味着烧瓶应通过nginx和gunicorn供应。我建立了一个示例代码库https://github.com/geoHeil/pythonServing,但是到目前为止还不能让nginx正常工作。

烧瓶放在application:5000上,docker应将应用程序解析为其各自的名称。

Nginx配置如下:

server {

    listen 8080;
    server_name application;
    charset utf-8;

    location / {
        proxy_pass http://application:5000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

我觉得不错。到目前为止我还找不到问题。

编辑

撰写文件在这里。启动命令是

docker-compose build
docker-compose up

version: '2'
services:
  application:
    restart: always
    build: ./application
    command: gunicorn -w 4 --bind :5000 wsgi:application
    links:
      - db
    expose:
     - "5000"
    ports:
      - "5000:5000"
  nginx:
    restart: always
    build: ./nginx
    links:
      - application
    expose:
      - 8080
    ports:
      - "8880:8080"

Tags: composedockerbuildserver烧瓶applicationnginxlinks

热门问题