fix: Configure multi-node backend nodes for internal networking (no port conflicts)

This commit is contained in:
Alexis Bruneteau 2025-11-07 02:42:07 +01:00
parent 5ac2a49a2a
commit f83bd796dd
2 changed files with 14 additions and 15 deletions

View File

@ -55,12 +55,11 @@ docker-compose -f docker-compose.multinode.yml ps
|-----------|-----|---------|
| **Frontend** | http://localhost:3000 | Voting interface |
| **Load Balancer** | http://localhost:8000 | Routes to all backend nodes |
| **Node 1 Direct** | http://localhost:8001 | Direct access to node 1 |
| **Node 2 Direct** | http://localhost:8002 | Direct access to node 2 |
| **Node 3 Direct** | http://localhost:8003 | Direct access to node 3 |
| **API Docs** | http://localhost:8000/docs | API documentation |
| **Database UI** | http://localhost:8081 | Database management (Adminer) |
**Note**: Backend nodes are internal to the Docker network and only accessible through Nginx load balancer on port 8000. This is more efficient and prevents port conflicts.
## How It Works
### Load Balancing

View File

@ -29,7 +29,7 @@ services:
start_period: 40s
# ================================================================
# Backend Node 1 (Port 8001)
# Backend Node 1 (Internal Port 8000, No external binding)
# ================================================================
backend-node-1:
build:
@ -47,9 +47,9 @@ services:
DEBUG: ${DEBUG:-false}
PYTHONUNBUFFERED: 1
NODE_ID: node1
NODE_PORT: 8001
ports:
- "8001:8000"
NODE_PORT: 8000
expose:
- "8000"
depends_on:
mariadb:
condition: service_healthy
@ -67,7 +67,7 @@ services:
start_period: 40s
# ================================================================
# Backend Node 2 (Port 8002)
# Backend Node 2 (Internal Port 8000, No external binding)
# ================================================================
backend-node-2:
build:
@ -85,9 +85,9 @@ services:
DEBUG: ${DEBUG:-false}
PYTHONUNBUFFERED: 1
NODE_ID: node2
NODE_PORT: 8002
ports:
- "8002:8000"
NODE_PORT: 8000
expose:
- "8000"
depends_on:
mariadb:
condition: service_healthy
@ -105,7 +105,7 @@ services:
start_period: 40s
# ================================================================
# Backend Node 3 (Port 8003)
# Backend Node 3 (Internal Port 8000, No external binding)
# ================================================================
backend-node-3:
build:
@ -123,9 +123,9 @@ services:
DEBUG: ${DEBUG:-false}
PYTHONUNBUFFERED: 1
NODE_ID: node3
NODE_PORT: 8003
ports:
- "8003:8000"
NODE_PORT: 8000
expose:
- "8000"
depends_on:
mariadb:
condition: service_healthy