1

我有一个auth服务(node.js 后端,fastify),nextjs服务于 SSR 反应应用程序和 traefik 作为前面的反向代理的服务。使用当前配置,应用程序可以正确提供,但我正在502 Bad Gateway获取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
4

1 回答 1

3

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

await fastify.listen(5000) //change to:
await fastify.listen(5000, '0.0.0.0')
于 2019-06-20T11:13:39.260 回答