【发布时间】:2021-01-17 08:19:14
【问题描述】:
我有 2 个使用 Docker Compose 部署的 Windows Server Docker 容器。一个容器运行反向代理服务器,另一个容器运行 Web 服务器。 Web 服务器提供一个简单的 index.html 页面。两者都在运行 Nginx。
运行时,一切都按预期工作。我可以通过代理访问内容。但是,如果我重新启动 Web 服务器,我会收到错误的网关错误。然后我需要重新启动代理才能让它再次工作。
如何在无需重新启动代理的情况下使其正常工作?
Docker 撰写:
version: '3'
services:
web:
build:
context: ./web
dockerfile: ./dockerfile
proxy:
build:
context: ./proxy
dockerfile: ./dockerfile
ports:
- "8089:80"
代理 Dockerfile:
FROM sixeyed/nginx:windowsservercore
COPY nginx.conf C:/nginx/conf
CMD C:\nginx\nginx.exe
代理 nginx.config:
events {
}
http {
server {
listen 80;
server_name localhost;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://web:80/;
}
}
}
Web Dockerfile:
FROM sixeyed/nginx:windowsservercore
COPY nginx.conf C:/nginx/conf
COPY index.html C:/nginx/html/index.html
CMD C:\nginx\nginx.exe
Web nginx.config:
events {
}
http {
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
}
}
【问题讨论】:
标签: docker nginx docker-compose network-programming windows-server