工作了两天,我还是被卡住了。我运行单独的nginx和应用程序容器。应用程序容器有一个在端口8000上运行gunicorn进程的flask应用程序。在
每当我导航到本地主机上的nginx端口80映射到的localhost:8080
时,我都会看到一个加载屏幕和nginx504错误。在
码头工人-合成.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=info -b :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
nginx.conf公司
^{pr2}$nginx Dockerfile
FROM nginx:latest
RUN rm /etc/nginx/conf.d/default.conf
COPY ./nginx.conf /etc/nginx/conf.d/nginx.conf
我会提供更多的信息,如果需要得到一些帮助这个问题上,我正在努力。在
好吧,三天后我的头撞了,我重新从头开始。重新构建应用程序容器并运行gunicorn。
从那里我可以确定gunicorn进程超时是因为数据库主机名不正确。我的应用程序并没有返回一个错误,失败变得无声。
我通过链接postgres容器和web容器修复了这个问题。在我的代码中,我能够使用“postgres”(容器的名称)作为postgres主机名。
检查外部主机的地址。
NGINX响应504表示网关超时,因为NGINX无法连接后端服务器。因此,您可以在proxy_pass目录找到问题。
我猜NGINX无法解析
web
域名,有两种解决方案:而不是IP
位置/{
}
使用上游
上游网{
^{pr2}$}
位置/{
}
相关问题 更多 >
编程相关推荐