From Confusion to Clarity: Deploy your first web App using Nginx in AWS EC2 (and Why It Matters!)

Harish SelvaHarish Selva
4 min read

“Okay, I deployed my static site into Nginx on AWS(Don’t worry - I will tell you how I did this in the later part of this blog). Zero configs. yet worked. But… why does everyone make a big deal out of this thing?”

That was me. A few weeks ago.

I had just completed a basic web deployment — dropped my static files into the default Nginx folder, spun up an AWS EC2 instance, and finally: my website was live. No configuration. No magic spells. Just raw HTML/CSS/JS.

I was happy. But also curious!

I can hear you - Why Nginx? What’s the Big Deal?

Curios about Nginx? check out my previous blog! - What’s NGINX

Everyone in the dev world seems to recommend Nginx. I had heard words like "reverse proxy", "load balancer", "static file server", and "web server" thrown around.

But I asked the one question:

“If I didn’t configure anything, what exactly am I gaining from using Nginx?”

What You Get from Nginx by Default

When I deployed my site into Nginx with zero custom config, here’s what I got out of the box:

  • ⚡ Super-fast static file serving

  • 📥 Efficient handling of multiple client requests

  • 🧠 Connection queuing — no overload on my backend

  • 🧱 Basic security headers and structure

  • 💪 Better scalability than serving files using plain Node or Python servers

No configuration. Just benefits.
That’s the beauty of using Nginx even at its most basic.

Then I Asked: “How Many Users Can My Instance Handle?”

I deployed my Nginx-based site on an EC2 t2.micro instance (1 vCPU, 1GB RAM). Naturally, I wondered:

“How many users can hit my site per second without it falling apart?”

Here’s what I found:

  • Nginx can handle hundreds to a few thousand requests per second on small instances like t2.micro.

  • Simultaneous connections? Around 100 to 200 with good performance, even more with tuning.

  • Real numbers vary depending on: static/dynamic content, instance size, and load type.

So yes — for basic sites, you’re in safe hands with Nginx and a small instance.

But What About Dynamic Websites?

Here’s where it gets even better.

Is Nginx just for static websites?

NOPE.

In fact, Nginx shines when used with dynamic backends like:

  • Node.js

  • Flask

  • Django

  • PHP

  • Spring Boot

  • …you name it!

Is Nginx a Best Practice?

Yes, it is.
Even without deep config, it gives you:

  • Out-of-the-box speed

  • Better connection handling

  • Security perks

  • Production resilience

Whether you’re serving a static portfolio, a React SPA, or a backend API — putting Nginx in front is a low-effort, high-impact move.

So next time you deploy, ask yourself:

“Why not let Nginx take care of the heavy lifting?”

now let us come to the AWS deployment part!

Deploying your app on nginx in ec2 is simple, follow the steps below:

1. Launch EC2 Instance

  • Go to AWS Console → EC2 → Launch Instance.

  • Choose Amazon Linux 2 / Ubuntu (recommended).

  • Choose instance type (e.g., t2.micro for free tier).

  • Configure key pair for SSH.

  • Open ports in Security Group:

    • 22 (SSH)

    • 80 (HTTP)

    • 443 (HTTPS) — optional

2. Connect to EC2 via SSH

ssh -i "your-key.pem" ec2-user@<EC2-Public-IP>
# OR if Ubuntu:
ssh -i "your-key.pem" ubuntu@<EC2-Public-IP>

3. Install Node.js, npm, and NGINX

# For Amazon Linux:
curl -sL https://rpm.nodesource.com/setup_18.x | sudo bash -
sudo yum install -y nodejs nginx

# For Ubuntu:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs nginx

4. Upload Your React App

Choose one of the methods:

SCP (from your local machine):

scp -i "your-key.pem" -r ./build ubuntu@<EC2-Public-IP>:~/react-app

If you have your code in git repository, then it is even simple just do this!

Git Clone (inside EC2):

git clone https://github.com/yourusername/your-react-repo.git
cd your-react-repo
npm install
npm run build

This creates a build/ directory with static files.

5. Configure NGINX

Edit the default config:

sudo vim /etc/nginx/nginx.conf

OR better (on Ubuntu):

sudo vim /etc/nginx/sites-available/default

Replace location / block with:

location / {
    root /home/ubuntu/react-app/build;
    index index.html index.htm;
    try_files $uri /index.html;
}

Make sure the root path points to the correct build directory.

6. Restart NGINX

sudo systemctl restart nginx
sudo systemctl enable nginx

7. Access Your React App

Visit:

http://<EC2-Public-IP>

If you see your React app, you're all set!

To Summarize for you!

  • Build React app → npm run build

  • Upload to EC2 → /home/ubuntu/react-app/build

  • Configure NGINX → serve from build/ directory

  • Restart NGINX → done!

💬 Let me know your Nginx moment in the comments.

0
Subscribe to my newsletter

Read articles from Harish Selva directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Harish Selva
Harish Selva