惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
D
DataBreaches.Net
C
Check Point Blog
雷峰网
雷峰网
小众软件
小众软件
GbyAI
GbyAI
美团技术团队
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
WordPress大学
WordPress大学
MyScale Blog
MyScale Blog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
Apple Machine Learning Research
Apple Machine Learning Research
Y
Y Combinator Blog
Jina AI
Jina AI
爱范儿
爱范儿
Last Week in AI
Last Week in AI
MongoDB | Blog
MongoDB | Blog
I
InfoQ
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How I Host Multiple Node.js Applications on a Single AWS ...
Ankiit janggid · 2026-06-12 · via DEV Community

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.

node

aws

devops

webdev