docker - curl to traefik 在 docker 内部工作,但不在外部
问题描述
我尝试使用 traefik 进行负载平衡。这是我的 docker-compose.yml
version: "3.3"
services:
reverse-proxy:
image: traefik
command: --api.insecure=true --providers.docker #--configFile=treafik.toml
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
whoami:
# A container that exposes an API to show its IP address
image: containous/whoami
labels:
- "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)"
我使用三个 whoami 副本和一个反向代理副本
当我在码头外尝试时curl -H Host:whoami.docker.localhost http://127.0.0.1
,我得到 404 not found
但是当我在 docker 内部使用时,它给了我实际值
我不知道为什么它在 docker 之外不起作用
解决方案
推荐阅读
- java - 对 Spring 端点的 Java 请求
- npm - npm v7 的“预卸载”生命周期脚本的替代方案
- go - 不能在变量声明中使用 make(IntChannel)(IntChannel 类型的值)作为消费者值
- html - 如何使用 vba 从网站表中提取数据
- reactjs - 用状态反应嵌套的 Hooks
- windows - 为什么有时 powershell cmdlet“select-string”不返回任何值?
- excel - Maats Laravel Excel
- css - Material-UI 嵌套网格的响应式设计问题
- python - 自动识别日期时间列
- geolocation - 匿名/聚合纬度/经度坐标