AWS Builder Center

Deploying a Full-Stack Application on AWS EC2: A Practical Beginner’s Guide

Learn how to deploy a real-world Node.js application on Amazon EC2, configure security groups, connect to the server through SSH, and serve your application securely using Nginx.

Cloud deployment can feel confusing when you're learning it for the first time. There are many AWS services, networking concepts, security configurations, and deployment strategies to understand.
One of the best ways to learn, however, is to deploy a real application yourself.
In this article, I'll walk through the fundamentals of deploying a web application on Amazon EC2, from creating the server to making the application accessible over the internet.

What We Will Build

The basic architecture will look like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
User
|
| HTTP/HTTPS
v
Internet
|
v
AWS EC2
|
+--> Nginx
|
+--> Node.js Application
|
+--> Database / External Services
The goal is not just to launch an EC2 instance, but to understand what happens behind the scenes.

1. What Is Amazon EC2?

Amazon EC2 (Elastic Compute Cloud) provides virtual servers in the AWS cloud.
Instead of purchasing a physical server, we can create an instance with the CPU, memory, storage, and operating system we need.
For example, an EC2 instance can run:
  • Node.js applications
  • Python/FastAPI applications
  • Java/Spring Boot applications
  • Docker containers
  • Nginx
  • Databases for development purposes
  • Background workers
For a beginner, EC2 is a great way to understand how traditional servers work while still using cloud infrastructure.

2. Create an EC2 Instance

From the AWS Console, create an EC2 instance.
For a learning project, you can select an eligible low-cost or free-tier configuration depending on your AWS account and current AWS pricing/eligibility.
Choose an operating system such as:
1
Amazon Linux
Then configure:
  • Instance type
  • Key pair
  • Storage
  • Network
  • Security group
The key pair is particularly important because it allows you to authenticate to the server using SSH.

3. Understanding Security Groups

One of the most important AWS concepts I learned while working with EC2 is the Security Group.
A security group works like a virtual firewall around your instance.
For example:
ProtocolPortPurpose
SSH22Connect to server
HTTP80Web traffic
HTTPS443Secure web traffic
A common mistake beginners make is opening every port to the internet.
For example:
1
0.0.0.0/0
means the port is accessible from anywhere.
For SSH, it is better to restrict access to your own IP address whenever practical.
Never open unnecessary ports just because they make development easier.

4. Connect to the EC2 Server

After launching the instance, AWS provides connection information.
From a terminal, an SSH connection generally looks like:
1
ssh -i my-key.pem ec2-user@YOUR_PUBLIC_IP
Once connected, you're working directly inside your cloud server.
You can verify the operating system with:
1
uname -a
and check your current directory with:
1
pwd
This is where the cloud starts feeling much more tangible: you're essentially managing a Linux machine running somewhere in an AWS data center.

5. Install Node.js

If you're deploying a Node.js application, install the required Node.js version on the server.
Then verify:
1
2
node --version
npm --version
Next, transfer or clone your application onto the server.
For example:
1
2
3
git clone YOUR_REPOSITORY
cd your-project
npm install
Then start the application:
1
npm start
At this point, the application may be running on something like:
1
http://YOUR_PUBLIC_IP:3000
But this isn't the setup we normally want for production.
That's where Nginx comes in.

6. Why Do We Need Nginx?

Instead of exposing our Node.js application directly to the internet, we can put Nginx in front of it.
The architecture becomes:
1
2
3
4
5
6
7
8
9
Browser
|
| HTTPS
v
Nginx :443
|
| Reverse Proxy
v
Node.js :3000
Nginx receives the incoming request and forwards it to our Node.js application.
This is called a reverse proxy.
It also gives us a clean place to handle:
  • HTTPS
  • Domain names
  • Request routing
  • Static files
  • Reverse proxying
  • Load balancing

7. Run the Node.js Application as a Service

We don't want our application to stop every time we close our SSH session.
A process manager such as PM2 can help keep a Node.js application running.
For example:
1
npm install -g pm2
Then:
1
pm2 start app.js
Check the application:
1
pm2 status
PM2 can restart the application if it crashes and can also help keep it running after server restarts.

8. Configure Nginx

Now Nginx can forward requests to our Node.js server.
Conceptually:
1
2
3
4
5
6
7
8
9
server {
listen 80;

server_name example.com;

location / {
proxy_pass http://localhost:3000;
}
}
Now users don't need to know that the Node.js application is running on port 3000.
They simply visit:
1
http://example.com
and Nginx forwards the request internally.

9. Add HTTPS

For a production application, HTTPS is essential.
Instead of:
1
http://example.com
we want:
1
https://example.com
A common approach is to use a trusted TLS certificate and configure Nginx to terminate HTTPS connections.
The final architecture becomes:
1
2
3
4
5
6
7
8
9
10
11
12
13
AWS EC2
|
+-----+-----+
| Nginx |
| :443 |
+-----+-----+
|
Reverse Proxy
|
+-----+-----+
| Node.js |
| :3000 |
+-----------+

10. What I Learned From Deploying on EC2

The most valuable part of working with EC2 isn't simply getting an application online.
It's understanding the different layers involved.
I learned that deploying an application involves much more than writing code:
1
2
3
4
5
6
7
8
9
10
11
Application
↓
Process Management
↓
Web Server
↓
Networking
↓
Security
↓
Cloud Infrastructure
This helped me understand concepts such as:
  • Linux server administration
  • SSH
  • Security Groups
  • Ports
  • Reverse proxies
  • Nginx
  • DNS
  • HTTPS
  • Process management
  • Cloud networking
These concepts are useful regardless of whether you're working with Node.js, Python, Java, or another backend technology.

11. What's Next?

Once you understand a basic EC2 deployment, there are many directions to explore.
You can gradually introduce:
  • Docker
  • Amazon ECR
  • Application Load Balancer
  • Auto Scaling
  • Amazon RDS
  • Amazon S3
  • CloudFront
  • Route 53
  • CloudWatch
  • CI/CD with GitHub Actions
  • ECS
  • Infrastructure as Code
A possible future architecture could look like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Users
|
v
Route 53
|
v
Load Balancer
|
+--------+--------+
| |
EC2 EC2
| |
Docker Docker
| |
Backend Backend
+--------+--------+
|
RDS

Conclusion

Learning AWS becomes much easier when you stop treating it as a collection of services and start building real systems.
EC2 is a great starting point because it forces you to understand what actually happens when an application goes from your local computer to a production server.
Start small:
Create an EC2 instance → connect with SSH → deploy your application → configure security → add Nginx → enable HTTPS → automate the deployment.
Once these fundamentals become comfortable, services such as ECS, ECR, RDS, S3, CloudFront, and load balancers become much easier to understand.
Cloud isn't just about knowing AWS services.
It's about understanding how software runs in the real world.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article