首页 > 解决方案 > Traefik2 将多个服务路由到烧瓶中的多个子路径

问题描述

我对烧瓶运行的多个服务有疑问。如果我评论服务 app1 或 app2,一切正常。但是当我同时运行两个服务和“curl localhost/app1”时,我得到了 404 错误。“curl localhost/app2”效果很好。

这是 docker-compose.yml。

version: "2.4"

services:

  traefik:
    image: "traefik:v2.1.3"
    container_name: "traefik"
    command:
      #- "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

  app1:
    image: pytorch:1.4.0
    build:
      context: .
      target: prod
      dockerfile: ./app1/Dockerfile
    labels:
      - traefik.enable=true
      - "traefik.http.routers.app1.rule=Path(`/app1`)"
      - "traefik.http.routers.app1.entrypoints=web"

  app2:
    image: pytorch:1.4.0
    build:
      context: .
      target: prod
      dockerfile: ./app2/Dockerfile
    labels:
      - traefik.enable=true
      - "traefik.http.routers.app2.rule=Path(`/app2`)"
      - "traefik.http.routers.app2.entrypoints=web"

标签: flasktraefik

解决方案


推荐阅读