【发布时间】:2018-11-06 19:50:20
【问题描述】:
我让 docker compose 和 nginx 一起运行,配置如下:
version: "3"
services:
web:
image: nginx:alpine
volumes:
- ./nginx:/etc/nginx/conf.d/rainloop
ports:
- "8081:80"
labels:
- "traefik.frontend.rule=Host:www.example.com"
- "traefik.port=8081"
和 docker-compose 中的 traefik 使用以下配置:
version: '3'
services:
reverse-proxy:
image: traefik:alpine
command: --api --docker
ports:
- "80:80" # The HTTP port
- "8080:8080" # The Web UI (enabled by --api)
volumes:
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
- ./traefik.toml:/etc/traefik/traefik.toml
traefik.toml 保持基本,看起来像这样
defaultEntryPoints = ["http"]
[entryPoints]
[entryPoints.http]
address = ":80"
Web UI 显示以下内容
当调用我的域 www.example.com 时,我遇到了超时。
【问题讨论】:
-
将 traefik 服务和您的“网络”服务放在同一个网络上。通常,您会将网络 traefik 指定为您自己服务堆栈中的外部网络,并将您希望通过 traefik 访问的服务分配给该网络。省略 traefik 无法访问的支持容器(例如数据库或 memcached)
-
你能举个例子吗?我尝试的方法也没有奏效。
标签: docker nginx reverse-proxy traefik