首页 > 解决方案 > 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 之外不起作用

标签: dockertraefik

解决方案


推荐阅读