단일 AWS Lightsail 서버에서 여러 Node.js 애플리케이션을 호스팅하는 방법

작성자

카테고리:

← 피드로
DEV Community · Ankiit janggid · 2026-06-12 개발(SW)
Cover image for How I Host Multiple Node.js Applications on a Single AWS Lightsail Server

Ankiit janggid

A few years ago, whenever I started a new project, I thought:

“This project needs its own server.”

After a while, that approach became expensive, difficult to manage, and honestly unnecessary for many business applications.

Today, I host multiple Node.js applications on a single AWS Lightsail instance using Apache Virtual Hosts and PM2.

This setup has helped me reduce infrastructure costs, simplify deployments, and manage projects more efficiently.

Here’s how it works.

Why I Chose AWS Lightsail

For many business applications, AWS Lightsail provides:

Predictable pricing
Full server control
Easy scalability
Good performance for small and medium projects

Instead of spinning up separate servers for every client or internal application, I consolidate multiple applications on a single instance.

My Architecture

The basic flow looks like this:

Internet


Apache Reverse Proxy

┌──┼───────────┐
│ │ │
▼ ▼ ▼
App 1 App 2 App 3
3001 3002 3003

  PM2

Enter fullscreen mode Exit fullscreen mode

Apache handles incoming traffic and routes requests to the correct application.

PM2 keeps all Node.js applications running.

Folder Structure

I typically organize projects like this:

/var/www/
├── client-project-1
├── client-project-2
├── internal-app
└── admin-panel

Each project has:

Separate repository
Separate environment variables
Separate PM2 process

This keeps deployments clean.

Why PM2 Is Essential

Running Node.js applications directly is risky.

If the process crashes, your application goes offline.

PM2 provides:

Auto restart
Monitoring
Logs
Startup scripts
Process management

Example:

pm2 start server.js –name client-project-1
pm2 save
pm2 startup

After a reboot, everything comes back automatically.

Apache Virtual Hosts

Each domain points to a different internal port.

Example:


ServerName project1.com

ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/

Enter fullscreen mode Exit fullscreen mode

Another application:


ServerName project2.com

ProxyPass / http://localhost:3002/
ProxyPassReverse / http://localhost:3002/

Enter fullscreen mode Exit fullscreen mode

The user never sees the internal ports.

Everything feels like a normal website.

Biggest Benefits
Lower Costs

Instead of paying for multiple servers, several projects can share one instance.

Easier Maintenance

One server.

One monitoring setup.

One backup strategy.

Faster Deployments

Deployments become predictable and repeatable.

Better Resource Usage

Most business applications never fully utilize an entire server.

Mistakes I Learned to Avoid

A few mistakes I made early on:

Running applications without PM2
Exposing internal ports publicly
Forgetting SSL configuration
Mixing all projects in one folder
Not monitoring logs

Fixing these made the setup much more stable.

When I Wouldn’t Use This Setup

I would choose dedicated infrastructure when:

Traffic becomes very high
Security requirements are strict
Applications consume significant resources
Microservice architecture becomes necessary

For many small and medium business projects, though, a single Lightsail instance works surprisingly well.

Final Thoughts

One of the biggest lessons I’ve learned is that infrastructure doesn’t need to be complicated.

A simple combination of:

AWS Lightsail
Apache
PM2
Node.js

can power multiple production applications reliably and cost-effectively.

How are you hosting your Node.js applications today?

I’d love to hear your setup in the comments.

node

aws

devops

webdev

원문에서 계속 ↗

코멘트

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다