Traefik 502 错误网关 |配置错误? |固定 nextjs

Traefik 502 bad gateway | Wrong config? | fastify nextjs

我有一个 auth 服务(node.js 后端,fastify),nextjs 服务服务于 SSR 反应应用程序和 traefik 作为前面的反向代理。 使用当前配置,应用程序可以正常运行,但我得到 502 Bad Gateway for auth.

// traefik.toml

[entryPoints]
    [entryPoints.http]
       address = ":80"
[api]

// traefik docker-compose
version: '3'

networks:
  default:
    external:
      name: traefik_default

services:
  reverse-proxy:
    image: traefik
    command: --docker
    ports:
      - "80:80"
      - "8080:8080" # The Web UI (enabled by --api)
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik.toml:/traefik.toml
// auth docker-compose

version: "3.7"

networks:
  default:
    external:
      name: traefik_default

services:
  auth:
    build: .
    labels:
     - "traefik.frontends=auth"
     - "traefik.frontend.rule=Host:auth.app.loc"
     - "treafik.port=80"
     - "traefik.backends=backend_auth"
    volumes:
      - .:/usr/src/app
      - /usr/src/app/node_modules
    ports:
      - 5000
    command: node .
// nextjs app docker-compose

version: "3.7"

networks:
  default:
    external:
      name: traefik_default

services:
  nextjs:
    build: .
    labels:
     - "traefik.frontends=nextjs"
     - "traefik.frontend.rule=Host:app.loc"
     - "treafik.port=80"
     - "traefik.backends=backend_nextjs"
    volumes:
      - .:/usr/src/app
      - /usr/src/app/node_modules
    ports:
      - 3000
    command: npm run dev

问题是fastify监听127.0.0.1接口,需要改为0.0.0.0监听所有接口

await fastify.listen(5000) //change to:
await fastify.listen(5000, '0.0.0.0')