I'm new to using Traefik and for the past days, I've been struggling with connecting my frontend application with my backend (NestJS) application despite having enabled sticky session, here is my compose file:
services:
reverse-proxy:
image: traefik:v3.1
command: --api.insecure=true --providers.docker
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
nest-server:
build:
context: .
dockerfile: Dockerfile.dev
volumes:
- .:/app
env_file:
- .env
environment:
- NODE_ENV=development
- TIMESCALE_HOST=timescale-db
- RABBITMQ_HOST=message-broker
command: npm run start:dev
depends_on:
- timescale-db
- message-broker
deploy:
replicas: 3
labels:
- "traefik.http.routers.nest-server.rule=Host(`nest-server.localhost`)"
- "traefik.http.services.nest-server.loadBalancer.sticky.cookie.name=server_id"
- "traefik.http.services.nest-server.loadBalancer.sticky.cookie.httpOnly=true"
timescale-db:
image: timescale/timescaledb-ha:pg16
container_name: ec-statistics-database
volumes:
- ./timescale-data:/var/lib/postgresql/data
ports:
- "5432:5432"
environment:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_DB=${POSTGRES_DATABASE}
message-broker:
image: rabbitmq:4.0.2
container_name: rabbitmq
environment:
- RABBITMQ_DEFAULT_USER=${RABBITMQ_USERNAME}
- RABBITMQ_DEFAULT_PASS=${RABBITMQ_PASSWORD}
In the network tab, I mostly get 400 BAD REQUEST
errors with the response body: {"code":1,"message":"Session ID unknown"}