【发布时间】:2021-11-13 22:49:23
【问题描述】:
所以我想做的是拥有两个网络应用:appli1 和 appli2。
当我从浏览器访问 x.x.x.x:8000 时,appli1 运行良好,但使用 x.x.x.x:8001 我没有得到 appli2,但我又得到了 appli1。那么我怎样才能让它正常工作呢?
这是我的 docker-compose 文件:
version: '3'
services:
reverse-proxy:
image: nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
ports:
- 8000:8000
- 8001:8001
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
depends_on:
- redis
environment:
- REDIS_HOST=redis
#ports:
#- "8000:8000"
web2:
build: .
command: python manage.py runserver 0.0.0.0:8001
depends_on:
- redis
environment:
- REDIS_HOST=redis
redis:
image: redis:3.2-alpine
volumes:
- redis_data:/data
volumes:
redis_data:
这是我的 nginx.conf 文件:
events {
}
http {
server {
listen 8000;
server_name web.appli1.com;
location / {
proxy_pass http://web:8000;
}
}
server {
listen 8001;
server_name web2.appli2.com;
location / {
proxy_pass http://web2:8001;
}
}
}
这是我的 dockerfile:
FROM python:3
ENV PYTHONUNBUFFERED 1
WORKDIR /app
ADD . /app
COPY ./requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
COPY . /app
CMD . /app/djangodocker/
我还使用主机的 ip 在 /etc/hosts 中设置域
【问题讨论】:
-
那么你的问题是什么?
-
请添加您的 Dockerfiles
-
我已经编辑并添加了 dockerfile