Docker Traefik未将请求路径传递给Strapi CMS

Docker Traefik未将请求路径传递给Strapi CMS,docker,docker-compose,traefik,strapi,Docker,Docker Compose,Traefik,Strapi,我试图让Traefik和Stapi CMS一起工作,但在尝试访问管理面板时遇到了问题。例如,我将部署这两个服务,并通过CMS.example.com访问CMS,它将按照预期的strapi加载public/index.html 问题是当我尝试访问cms.example.com/admin时,请求再次返回public/index.html页面,而不是admin页面。我还检查了两个请求上的strapi输出,它似乎在请求相同的路由 有人能告诉我如何识别错误是Traefik没有发送路径还是Strapi爆炸

我试图让Traefik和Stapi CMS一起工作,但在尝试访问管理面板时遇到了问题。例如,我将部署这两个服务,并通过CMS.example.com访问CMS,它将按照预期的strapi加载public/index.html

问题是当我尝试访问cms.example.com/admin时,请求再次返回public/index.html页面,而不是admin页面。我还检查了两个请求上的strapi输出,它似乎在请求相同的路由

有人能告诉我如何识别错误是Traefik没有发送路径还是Strapi爆炸了?

以下是有关部署的一些详细信息:

  • Traefik部署:
  • Strapi docker compose:
  • Traefik TOML文件:

    ################################################################
    # Global configuration
    ################################################################
    [global]
      checkNewVersion = true
      sendAnonymousUsage = true
    
    ################################################################
    # Entrypoints configuration
    ################################################################
    
    # Entrypoints definition
    #
    # Optional
    # Default:
    [entryPoints]
      [entryPoints.web]
        address = ":80"
    
      [entryPoints.websecure]
        address = ":443"
    
    ################################################################
    # Traefik logs configuration
    ################################################################
    
    # Traefik logs
    # Enabled by default and log to stdout
    #
    # Optional
    #
    [log]
    
      # Log level
      #
      # Optional
      # Default: "ERROR"
      #
       level = "INFO"
    
      # Sets the filepath for the traefik log. If not specified, stdout will be used.
      # Intermediate directories are created if necessary.
      #
      # Optional
      # Default: os.Stdout
      #
      filePath = "log/traefik.log"
    
      # Format is either "json" or "common".
      #
      # Optional
      # Default: "common"
      #
       format = "json"
    
    ################################################################
    # Access logs configuration
    ################################################################
    
    # Enable access logs
    # By default it will write to stdout and produce logs in the textual
    # Common Log Format (CLF), extended with additional fields.
    #
    # Optional
    #
    # [accessLog]
    
      # Sets the file path for the access log. If not specified, stdout will be used.
      # Intermediate directories are created if necessary.
      #
      # Optional
      # Default: os.Stdout
      #
      # filePath = "/path/to/log/log.txt"
    
      # Format is either "json" or "common".
      #
      # Optional
      # Default: "common"
      #
      # format = "json"
    
    ################################################################
    # API and dashboard configuration
    ################################################################
    
    # Enable API and dashboard
    [api]
    
      # Name of the related entry point
      #
      # Optional
      # Default: "traefik"
      #
      # entryPoint = "traefik"
    
      # Enabled Dashboard
      #
      # Optional
      # Default: true
      #
       dashboard = true
       insecure = true
    
    ################################################################
    # Ping configuration
    ################################################################
    
    # Enable ping
    [ping]
    
      # Name of the related entry point
      #
      # Optional
      # Default: "traefik"
      #
      # entryPoint = "traefik"
    
    ################################################################
    # Docker configuration backend
    ################################################################
    
    # Enable Docker configuration backend
    [providers.docker]
    
      # Docker server endpoint. Can be a tcp or a unix socket endpoint.
      #
      # Required
      # Default: "unix:///var/run/docker.sock"
      #
      # endpoint = "tcp://10.10.10.10:2375"
    
      # Default host rule.
      #
      # Optional
      # Default: "Host(`{{ normalize .Name }}`)"
      #
      # defaultRule = "Host(`{{ normalize .Name }}.docker.localhost`)"
    
      # Expose containers by default in traefik
      #
      # Optional
      # Default: true
      #
      network = "web"
      watch = true
      exposedByDefault = false
    

    通过首先手动构建Strapi管理UI,然后配置Traefik来路由请求,解决了这个问题

    version: '3.1'
    
        services:
      strapi:
        image: strapi/strapi
        environment:
          - DATABASE_CLIENT=postgres
          - DATABASE_HOST=strapi-db
          - DATABASE_PORT=5432
          - DATABASE_NAME=strapi
          - DATABASE_USERNAME=strapi
          - DATABASE_PASSWORD=strapi
        ports:
          - 9020:1337
        labels:
          - "traefik.enable=true"
          - "traefik.http.routers.circulate.rule=Host(`cms.circulate.co.za`)"
          - "traefik.http.routers.circulate.entrypoints=web"
          - "traefik.docker.network=web"
          - "traefik.http.middlewares.circulate.addprefix.prefix=/foo"
          - "traefik.port=80"
        networks:
          - internal
          - web
        volumes:
          - ./app:/srv/app
        depends_on:
          - strapi-db
        command: 'strapi start'
    
      strapi-db:
        image: postgres:12.1
        restart: always
        networks:
          - internal
          - web
        volumes:
          - strapi-vol:/var/lib/postgresql/data
        environment:
          POSTGRES_USER: strapi
          POSTGRES_PASSWORD: strapi
          POSTGRES_DB: strapi
    
    volumes:
      strapi-vol:
    
    networks:
      web:
        external: true
      internal:
        external: false
    
    
    ################################################################
    # Global configuration
    ################################################################
    [global]
      checkNewVersion = true
      sendAnonymousUsage = true
    
    ################################################################
    # Entrypoints configuration
    ################################################################
    
    # Entrypoints definition
    #
    # Optional
    # Default:
    [entryPoints]
      [entryPoints.web]
        address = ":80"
    
      [entryPoints.websecure]
        address = ":443"
    
    ################################################################
    # Traefik logs configuration
    ################################################################
    
    # Traefik logs
    # Enabled by default and log to stdout
    #
    # Optional
    #
    [log]
    
      # Log level
      #
      # Optional
      # Default: "ERROR"
      #
       level = "INFO"
    
      # Sets the filepath for the traefik log. If not specified, stdout will be used.
      # Intermediate directories are created if necessary.
      #
      # Optional
      # Default: os.Stdout
      #
      filePath = "log/traefik.log"
    
      # Format is either "json" or "common".
      #
      # Optional
      # Default: "common"
      #
       format = "json"
    
    ################################################################
    # Access logs configuration
    ################################################################
    
    # Enable access logs
    # By default it will write to stdout and produce logs in the textual
    # Common Log Format (CLF), extended with additional fields.
    #
    # Optional
    #
    # [accessLog]
    
      # Sets the file path for the access log. If not specified, stdout will be used.
      # Intermediate directories are created if necessary.
      #
      # Optional
      # Default: os.Stdout
      #
      # filePath = "/path/to/log/log.txt"
    
      # Format is either "json" or "common".
      #
      # Optional
      # Default: "common"
      #
      # format = "json"
    
    ################################################################
    # API and dashboard configuration
    ################################################################
    
    # Enable API and dashboard
    [api]
    
      # Name of the related entry point
      #
      # Optional
      # Default: "traefik"
      #
      # entryPoint = "traefik"
    
      # Enabled Dashboard
      #
      # Optional
      # Default: true
      #
       dashboard = true
       insecure = true
    
    ################################################################
    # Ping configuration
    ################################################################
    
    # Enable ping
    [ping]
    
      # Name of the related entry point
      #
      # Optional
      # Default: "traefik"
      #
      # entryPoint = "traefik"
    
    ################################################################
    # Docker configuration backend
    ################################################################
    
    # Enable Docker configuration backend
    [providers.docker]
    
      # Docker server endpoint. Can be a tcp or a unix socket endpoint.
      #
      # Required
      # Default: "unix:///var/run/docker.sock"
      #
      # endpoint = "tcp://10.10.10.10:2375"
    
      # Default host rule.
      #
      # Optional
      # Default: "Host(`{{ normalize .Name }}`)"
      #
      # defaultRule = "Host(`{{ normalize .Name }}.docker.localhost`)"
    
      # Expose containers by default in traefik
      #
      # Optional
      # Default: true
      #
      network = "web"
      watch = true
      exposedByDefault = false