Deploying React Static Site on EC2 using Nginx + HTTPS (Certbot)
1) Build React frontend locally
npm install
npm run build
This generates the production build in dist/ (Vite) or build/ (CRA).
2) Verify the build locally
Open the generated folder using VS Code Live Server (or any static server) and ensure the site works properly.
3) Buy a domain
Example:
4) Create an EC2 Ubuntu instance
- Choose Ubuntu (20.04 / 22.04)
- Instance type: t2.micro is enough for static hosting
- Security Group inbound rules:
- SSH (22) → your IP
- HTTP (80) → 0.0.0.0/0
- HTTPS (443) → 0.0.0.0/0
5) Allocate and attach Elastic IP
This ensures your server IP remains fixed.