docker - Traefik 2.0 网关超时

标签 docker docker-swarm traefik

仅通过 http 创建了一个具有 2 个服务的简单 Traefik 实例。我在这两种情况下都遇到网关超时,这是我创建服务和 traefik 代理的唯一文件。

version: '3.4'

services:
  reverse-proxy:
    image: traefik:2.0 # The official Traefik docker image
    ports:
      - "80:80"     # The HTTP port
      - "10553:8080"    # The Web UI (enabled by --api)
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
    networks:
      - default
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.network=demo_swarm_network"
      - "--providers.docker.exposedbydefault=false"      
      - "--providers.docker.swarmMode=true"
      - "--entrypoints.web.address=:80"
    deploy:
      mode: global
      placement:
        constraints:
          - node.role == manager
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: on-failure  
  xxxxx-authentication-api:
    image: xxxx_authentication_api_nightly:9999
    deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.docker.lbswarm=true"
        - "traefik.docker.network=demo_swarm_network"
        - "traefik.http.routers.authenticationapi.rule=PathPrefix(`/api/authentication`)"
        - "traefik.http.routers.authenticationapi.entrypoints=web"        
        - "traefik.http.services.xxxxx-authentication-api.loadbalancer.server.port=3000"
        - "traefik.http.services.xxxxx-authentication-api.loadbalancer.server.scheme=http"
      replicas: 1
      update_config:
        parallelism: 1
        delay: 10s
        order: stop-first
    command: node ./server.js
    environment:
      - NODE_ENV=authentication 
      - LOG_LEVEL=info 
      - NODE_CONFIG_DIR=./config
    networks:
      - default
    ports:
      - "3000"
  xxxxx-authentication-app:
    image: xxxxx_authentication_app_nightly:9999
    deploy:
      labels:
        - "traefik.enable=true"       
        - "traefik.docker.lbswarm=true"
        - "traefik.docker.network=demo_swarm_network"
        - "traefik.http.routers.authenticationapp.rule=PathPrefix(`/authentication`)"    
        - "traefik.http.routers.authenticationapp.entrypoints=web"
        - "traefik.http.services.xxxxx-authentication-app.loadbalancer.server.port=80"
        - "traefik.http.services.xxxxx-authentication-app.loadbalancer.server.scheme=http"
      replicas: 1
      update_config:
        parallelism: 1
        delay: 10s
        order: stop-first
    networks:
      - default
    ports:
      - "80"
networks:
  default:
    external:
      name: demo_swarm_network

服务已启动并正在运行,容器也是如此。 Traefik 也在运行,就在我尝试 localhost:80/api/authenticationlocalhost:80/authentication 时,我收到网关超时。

traefik 将我的请求发送到哪里?我已在主机端口中确认两个端点中的应用程序都在运行。

我的配置中缺少什么?

最佳答案

万岁!当我将 demo_swarm_network 网络更新为具有覆盖时,超时消失了。

关于docker - Traefik 2.0 网关超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61276649/

相关文章:

docker - 无法从我的 Docker 容器 ping Windows 主机

redis - 如何在 Docker 中运行 Redis 服务器和另一个应用程序?

docker - 微服务中的服务发现与docker中的服务发现

Docker - 服务的别名 DNS 条目 (CNAME)

kubernetes - 将子路径设置为 k3s 上后端服务的 'root' 路径?

traefik - 使用 Traefik 将路径重定向到同一个容器但不同的端口

python - 如何为 tensorflow 构建 docker 镜像?

docker - 在 HTTPS 上运行 docker 服务

traefik - Kubernetes 上的 Traefik UI 中缺少 "Recent HTTP Errors"

python - Docker不复制 Assets 文件夹