← Back to Projects
🔵

EpicBook + 3-Tier Book Review App on Azure

Two complete full-stack Azure deployments — private MySQL, Load Balancers, NAT Gateway, and the Jump Host pattern

PlatformMicrosoft Azure
ToolsAzure VNet · MySQL Flexible Server · ALB · NAT Gateway · Nginx · PM2
StackNode.js · Next.js 15 · MySQL · Express
Read on MediumView Article →

Project 1 — EpicBook

EpicBook on Azure VM with Private MySQL

Internet ↓ Public IP (Static) Nginx (Port 80) — Reverse Proxy ↓ Node.js/Express App (Port 8080) ↓ Azure Database for MySQL Flexible Server (Port 3306) — Private Access only (VNet Integration) — No public internet access to database — 54 books imported from seed files Network: VNet 10.0.0.0/16 Public Subnet 10.0.1.0/24 — VM lives here Private Subnet 10.0.2.0/24 — MySQL lives here (no public access) NSGs: Public NSG: Allow HTTP (80) + SSH (22) Private NSG: Allow MySQL (3306) ONLY from 10.0.1.0/24
CHALLENGE

SSH Key Permission Issue on Windows

Running chmod on a .pem file in the Downloads folder failed on Windows. Fix: copy the key to the home directory (~/) first, then chmod 400 — Windows blocks permission changes in system folders.

KEY LEARNING

Private Subnets + NSGs = Database Security

The private NSG only allows MySQL traffic from the VM subnet (10.0.1.0/24). Nobody on the internet can reach the database directly. Network segmentation is the first principle of cloud security.

3-Tier App with Load Balancers & NAT Gateway

Internet ↓ Public Load Balancer (web-public-lb) — Static Public IP ↓ Web VM — Next.js 15 + Nginx (Public Subnet 10.0.1.0/24) ↓ (via Nginx proxy_pass to private IP) Internal Load Balancer (app-internal-lb) — Private IP: 10.0.3.10 ↓ App VM — Node.js/Express (Private Subnet 10.0.3.0/24) — NO public IP — Only reachable via Web VM / Load Balancer ↓ Azure MySQL Flexible Server (Private Subnet 10.0.5.0/24) — SSL required for all connections 6 subnets: web×2, app×2, db×2 (across 2 availability zones) NAT Gateway: allows app VM to download packages without public IP Jump Host: SSH via Web VM → then SSH to App VM (10.0.3.4)
CHALLENGE

Private VM cannot install packages — no internet access

App VM in private subnet cannot reach the internet to run apt install. Solution: added a NAT Gateway to the app subnets. NAT allows outbound traffic to the internet while keeping the subnet completely inaccessible from inbound internet connections.

CHALLENGE

Browser cannot reach private IP 10.0.3.4 directly

The app runs on a private IP. Users cannot access it from their browser. Solution: Nginx on the Web VM acts as middleman — browser calls /api/books, Nginx forwards it to 10.0.3.4:3001, gets the response, returns it. The browser never knows the private IP exists.

KEY LEARNING

Always use PM2 startup on every deployment

Without pm2 startup and pm2 save, your app dies when the VM reboots. This is non-negotiable in production — verified on every deployment.

Lessons Learned

What I Took Away

Build Network First, Always

Every Azure resource needs a network. Plan VNet and subnets before touching anything else. Retrofitting network architecture after deployment is painful and error-prone.

Private Subnets Need NAT Gateways

Private means no inbound internet — but it also means no outbound internet by default. If you need to install packages or pull from GitHub on a private subnet, add a NAT Gateway first.

The Jump Host Pattern is Standard

Never give backend VMs a public IP. Always access them through a Web VM or dedicated Bastion host. This is industry-standard practice in production cloud environments.

Always Use SSL for Managed Databases

Azure MySQL requires SSL. Always include dialectOptions.ssl in your Sequelize config. Forgetting this means silent connection failures that are difficult to debug.

Azure VNetMySQL Flexible ServerLoad BalancerNAT GatewayNginxNode.jsNext.jsPM2Jump Host
Read Full Article on Medium →