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
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/
Another application:
ServerName project2.com
ProxyPass / http://localhost:3002/
ProxyPassReverse / http://localhost:3002/
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.
Top comments (0)