【发布时间】:2019-03-29 14:02:20
【问题描述】:
我在 docker-compose 中有一个 traefik:
version: '3'
networks:
proxy:
driver: bridge
services:
traefik:
container_name: traefik
image: traefik:v1.7.9
command: --api --docker
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik.toml:/etc/traefik/traefik.toml
- ./acme.json:/acme.json
networks:
- proxy
mydomain.com 下也有 nginx,我想只允许我的 ip 连接到它:
nginx:
build: ./nginx
networks:
- backend
- traefik_proxy
restart: always
labels:
traefik.enable: "true"
traefik.port: "80"
traefik.frontend.headers.allowedHosts: "1.2.3.4" # MyIp
traefik.frontend.rule: "Host:mysite.com,www.mysite.com"
当我访问 mysite.com 时出现 Bad Host 错误,并且标头中的 IP 是我服务器的 ip 而不是我的真实 ip。 P.S Docker 在 swarm 模式下,但是 nginx 和 traefik 使用本地 docker-compose 构建
【问题讨论】:
标签: docker docker-compose docker-swarm traefik