使用 Traefik 对具有 Swagger UI 和 MinIO 的多个 docker 容器进行反向代理会抛出未找到错误

anz*_*man 5 reverse-proxy swagger docker docker-compose traefik

我正在尝试使用 traefik 运行一些示例,该示例将建立一个具有 swagger ui 和 MinIO docker 容器的反向代理。localhost:70/swagger我希望可以在和上访问这两项服务localhost:70/minio

这是我的docker-compose.yml文件:

version: '3'

services:
  reverse-proxy:
    image: traefik:v2.2
    container_name: traefik-reverse-proxy
    command: --providers.docker --api.insecure=true --entrypoints.web.address=:80 --log.level=DEBUG
    ports:
      - "70:80"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
  swagger:
    image: swaggerapi/swagger-ui:v3.23.0
    container_name: swagger
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.swagger.rule=Host(`localhost`) && Path(`/swagger`)"
      - "traefik.http.routers.swagger.entrypoints=web"
      - "traefik.http.routers.swagger.service=swagger"
      - "traefik.http.services.swagger.loadbalancer.server.port=8080"
  minio:
    image: minio/minio:RELEASE.2019-12-24T23-04-45Z
    container_name: minio
    command: "server /data"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.minio.rule=Host(`localhost`) && Path(`/minio`)"
      - "traefik.http.routers.minio.entrypoints=web"
      - "traefik.http.routers.minio.service=minio"
      - "traefik.http.services.minio.loadbalancer.server.port=9000"
  whoami:
    image: "containous/whoami"
    container_name: whoami
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.rule=Host(`localhost`) && Path(`/whoami`)"
      - "traefik.http.routers.whoami.entrypoints=web"
      - "traefik.http.routers.whoami.service=whoami"
      - "traefik.http.services.whoami.loadbalancer.server.port=80"
Run Code Online (Sandbox Code Playgroud)

在我运行之后docker-compose up一切正常。我还包含了 whoami 服务只是为了测试,当我导航到 localhost:70/whoami 时它工作正常,因为我能够看到我的主机信息。但是我无法调用 localhost:70/minio 或 localhost:70/swagger。如果我尝试调用 swagger,它会返回 nginx 404 Not Found 和 traefik 容器日志消息,如下所示:

traefik-reverse-proxy | time="2020-05-05T11:15:37Z" level=debug msg="vulcand/oxy/roundrobin/rr: Forwarding this request to URL" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/swagger\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"],\"Accept-Encoding\":[\"gzip, deflate\"],\"Accept-Language\":[\"en-GB,en;q=0.5\"],\"Connection\":[\"keep-alive\"],\"Upgrade-Insecure-Requests\":[\"1\"],\"User-Agent\":[\"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0\"],\"X-Forwarded-Host\":[\"localhost:70\"],\"X-Forwarded-Port\":[\"70\"],\"X-Forwarded-Proto\":[\"http\"],\"X-Forwarded-Server\":[\"26cf421ccde8\"],\"X-Real-Ip\":[\"172.19.0.1\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"localhost:70\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.19.0.1:50548\",\"RequestURI\":\"/swagger\",\"TLS\":null}" ForwardURL="http://172.19.0.5:8080"
swagger          | 2020/05/05 11:15:37 [error] 26#26: *2 open() "/usr/share/nginx/html/swagger" failed (2: No such file or directory), client: 172.19.0.4, server: localhost, request: "GET /swagger HTTP/1.1", host: "localhost:70"
swagger          | 172.19.0.4 - - [05/May/2020:11:15:37 +0000] "GET /swagger HTTP/1.1" 404 126 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0"
Run Code Online (Sandbox Code Playgroud)

这似乎是路由问题,因为如果我导航到 swagger 服务器 IP,我就可以看到 petstore 规范。

那么,我该如何解决这个问题呢?我错过了什么吗?