Reputation: 593
I have an auth
service (node.js backend, fastify), nextjs
service that serves SSR react app and traefik acting as a reverse proxy in front.
With the current config the app is served correctly, but I'm getting 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
Upvotes: 1
Views: 1463
Reputation: 593
The issue is that fastify
listens on 127.0.0.1
interface, and needs to be changed to 0.0.0.0
to listen on all interfaces
await fastify.listen(5000) //change to:
await fastify.listen(5000, '0.0.0.0')
Upvotes: 3