DirectAdmin is a control panel for web hosting that helps manage domains, files, email, databases, and more—similar to cPanel, but generally faster and more lightweight.
With hosting from Webspesialisten, it is included technical help to get your Node.js up and working. We can help you automate things if you need – at no cost. We offer a free version of DirectAdmin for our customers (unlimited accounts).
We reccomend that you work with the «admin» user in shell, even though you also have access to root.
Instructions
This guide shows how to deploy a Node.js app called myapp on mydomain.com using Apache as a reverse proxy on a DirectAdmin server. This setup supports HTTPS, routing, and runs your app with PM2.
Note that by default, all domains are owned by a user named «admin» (/home/admin/domains/mydomain.com). You can create sub-users if you want more seperation.
📁 Recommended Folder Structure
/home/youruser/
└── domains/
└── mydomain.com/
├── public_html/ ← Can be empty or used for static files
└── myapp/ ← Your Node.js app
├── app.js
├── package.json
├── routes/
└── views/
🧠 Step 1: Run Your App with PM2
cd ~/domains/mydomain.com/myapp
nvm use 20 # Or your installed Node.js version
npm install
pm2 start app.js --name myapp
pm2 save
pm2 startup
Make sure your app.js
listens on the correct port:
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`myapp running on port ${port}`);
});
🔧 Step 2: Configure Apache Reverse Proxy
- Log in to DirectAdmin
- Go to Admin Level > Custom HTTPD Configurations > mydomain.com
- Click Customize
- Paste the following into the CUSTOMHTTPD section:
|*if !PROXY_OVERRIDE|
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
|*endif|
This forwards all traffic to your Node.js app running on port 3000.
🔒 Step 3: Enable SSL (Let’s Encrypt)
- Go to Account Manager > SSL Certificates
- Select «Free & automatic certificate from Let’s Encrypt»
- Check “Force SSL with HTTPS redirect”
📦 Bonus: Combine Node.js API + Static Frontend
To serve a static frontend from public_html
and route API calls to Node.js:
ProxyPass /api/ http://127.0.0.1:3000/api/
ProxyPassReverse /api/ http://127.0.0.1:3000/api/
This lets you serve:
https://mydomain.com/
→ static site or PHP-scriptshttps://mydomain.com/api/
→ Node.js backend
✅ Summary
Step | Task | Description |
---|---|---|
1️⃣ | Run Node.js app with PM2 | App runs on port 3000 in the background |
2️⃣ | Set up Apache reverse proxy | Traffic forwarded to your app |
3️⃣ | Enable SSL (Let’s Encrypt) | Enforce HTTPS securely |
4️⃣ | Optional static + API | Use Node.js for API, Apache for static files |
🎉 Done! Your Node.js app is now live on mydomain.com using Apache reverse proxy and HTTPS.