Docker · AWS EC2 · Nginx · MongoDB · React

Production-Grade 3-Tier Application

Problem

Deploy a full-stack application with strict network isolation between tiers, mimicking production architecture where the database is never externally exposed and Nginx is the sole entry point.

Architecture

3-Tier Architecture with Docker Network Isolationfrontend-networkbackend-networkdb-networkNginx:80 (exposed)Node.js API:3000 (internal)MongoDB:27017 (unexposed)Reactstatic buildnamed volume

Key Decisions

  • Custom Dockerfiles per tier — no generic images. Each service built from a minimal base with only required dependencies.
  • Isolated Docker bridge networks — frontend and backend on one network, backend and database on another. No tier can directly reach a non-adjacent tier.
  • Nginx as reverse proxy on Port 80 — the only externally exposed service. All API routing handled via location blocks.
  • Named Docker volumes for MongoDB — data persists across container restarts without host-path coupling.
  • Docker Compose orchestration — single `docker-compose up` brings the entire stack online with correct network topology.

Outcome

Achieved true tier-to-tier isolation mirroring enterprise production architecture. MongoDB entirely unexposed to the internet. Single-command deployment on any Docker-capable host.

Stack

DockerDocker ComposeAWS EC2NginxMongoDBReactNode.js