python - Docker Compose Nginx 内部服务器错误
问题描述
我有一个烧瓶应用程序,我想在我的 docker compose 文件中托管在 nginx 上,但是当我这样做时,它给了我一个Internal Server error
以下是一些重要文件:
码头工人-compose.yml
version: "3.8"
services:
th3pl4gu3:
container_name: portfolix
build: ./
networks:
- portfolix_net
ports:
- 8084:8084
restart: always
server:
image: nginx:1.17.10
container_name: nginx
depends_on:
- th3pl4gu3
volumes:
- ./reverse_proxy/nginx.conf:/etc/nginx/nginx.conf
ports:
- 80:80
networks:
- portfolix_net
networks:
portfolix_net:
name: portfolix_network
driver: bridge
nginx.conf:
server {
listen 80;
location / {
include uwsgi_params;
uwsgi_pass th3pl4gu3:8084;
}
}
烧瓶 Dockerfile
# Using python 3.8 in Alpine
FROM python:3.8-alpine3.11
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
ADD . /app
# Dependencies for uWSGI
RUN apk add python3-dev build-base linux-headers pcre-dev && pip install -r requirements.txt && apk update
# In case bash is needed
#RUN apk add --no-cache bash
# Tell the port number the container should expose
EXPOSE 8084
# Run the command
ENTRYPOINT ["uwsgi", "app.ini"]
应用程序.ini
[uwsgi]
module = run:app
master = true
processes = 5
http-socket = 0.0.0.0:8084
chmod-socket = 660
vacuum = true
die-on-term = true
现在,当我在没有 nginx 服务的情况下运行这个 docker-compose 时,它可以工作,但我希望它在 nginx 服务器上运行。知道为什么我会收到内部服务器错误吗?
解决方案
我能够使用以下 docker-compose 解决它:
version: "3.8"
services:
th3pl4gu3:
container_name: portfolix
build: ./
networks:
- portfolix_net
expose:
- 8084
restart: always
server:
image: nginx:1.17.10
container_name: nginx
depends_on:
- th3pl4gu3
volumes:
- ./reverse_proxy/nginx.conf:/etc/nginx/nginx.conf
ports:
- 8084:80
networks:
- portfolix_net
networks:
portfolix_net:
name: portfolix_network
driver: bridge
问题出在我的8084:8084
推荐阅读
- amazon-web-services - DynamoDB:由于 Log4j2 错误而无法安装
- r - R ggplot 无法设置对数轴限制
- node.js - 即使在 npm clean cache --force、unlink、rm -rf node_modules 等之后,npm 链接也会继续拉旧版本
- python - Asyncio & Discord.py - 如何在 True 时停止正在运行的命令?
- mediawiki - 如何在模板参数中传递管道
- javascript - How to embed a webpack bundled react app to another site
- javascript - 具有“严格动态”的外部脚本哈希需要脚本标签上的“完整性”属性?
- reactjs - 使用更少的文本传递道具
- python - 空间复杂性——重新分配和返回参数,而不是创建新变量来返回
- teradata - Teradata:我需要检查表中的行数,如果计数大于 1,我需要运行更新查询