![]() |
|
Guide Run a Node.js App on CyberPanel Behind Your Domain with SSL - Printable Version +- AdminsForum (https://adminsforum.com) +-- Forum: Free & open-source control panels (https://adminsforum.com/Forum-free-open-source-control-panels) +--- Forum: CyberPanel (https://adminsforum.com/Forum-cyberpanel) +---- Forum: CyberPanel Guides & Tutorials (https://adminsforum.com/Forum-cyberpanel-guides-tutorials) +----- Forum: CyberPanel Websites & OpenLiteSpeed Guides (https://adminsforum.com/Forum-cyberpanel-websites-openlitespeed-guides) +----- Thread: Guide Run a Node.js App on CyberPanel Behind Your Domain with SSL (/Thread-guide-run-a-node-js-app-on-cyberpanel-behind-your-domain-with-ssl) |
Run a Node.js App on CyberPanel Behind Your Domain with SSL - JAY - 11-14-2026 Run a Node.js App on CyberPanel Behind Your Domain with SSL (Tested) CyberPanel is built around PHP sites, and it has no "Node.js app" button. But you can still host a Node.js app on the same server: the app runs on a private port, a small service keeps it alive, and your CyberPanel website passes visitors to it, with the SSL certificate CyberPanel already manages. We set this up on a CyberPanel 3.0.8 server (Ubuntu 24.04) and tested each step. Which web server: our test server runs LiteSpeed Enterprise. Steps 1 to 3 are the same on any CyberPanel server. Step 4 (the proxy rule) is different on OpenLiteSpeed. See the note there. Step 1: Install Node.js Over SSH as root. Ubuntu 24.04's own package is the old Node.js 18 ( Code: apt-cache policy nodejsCode: curl -fsSL https://deb.nodesource.com/setup_22.x -o /root/nodesource_setup.sh
bash /root/nodesource_setup.sh
apt-get install -y nodejs
node -v
npm -vCode: v22.23.5Code: 10.9.9Step 2: Put the app in the website's home folder Create a normal website in CyberPanel for the domain first (with SSL). CyberPanel gives every website its own Linux user. Find it: Code: stat -c %U /home/yourdomain.com/public_htmlCode: cours5268Put the app next to public_html, not inside it, so nobody can download your source files through the web server: Code: mkdir -p /home/yourdomain.com/nodeappCode: /home/yourdomain.com/nodeapp/app.jsCode: const http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello from Node.js ' + process.version + '\n' + 'URL: ' + req.url + '\n');
});
server.listen(3100, '127.0.0.1', () => {
console.log('App listening on 127.0.0.1:3100');
});
Code: chown -R cours5268:cours5268 /home/yourdomain.com/nodeappStep 3: Keep it running with a service Create Code: /etc/systemd/system/nodeapp.serviceCode: [Unit]
Description=Node.js app for yourdomain.com
After=network.target
[Service]
User=cours5268
WorkingDirectory=/home/yourdomain.com/nodeapp
ExecStart=/usr/bin/node app.js
Restart=always
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.targetCode: systemctl daemon-reload
systemctl enable --now nodeapp
systemctl status nodeapp --no-pager
curl http://127.0.0.1:3100/testCode: Hello from Node.js v22.23.5
URL: /testCode: pkill -f "node app.js"Code: Restart=alwaysStep 4: Send the domain to the app In CyberPanel open Websites → your site → Config → Rewrite Rules, replace what's there with these two lines and click Save Rewrite Rules: Code: RewriteEngine On
RewriteRule ^(.*)$ http://127.0.0.1:3100/$1 [P,L]Code: [P]We opened Code: https://yourdomain.com/hello?name=testCode: Hello from Node.js v22.23.5
URL: /hello?name=testOn OpenLiteSpeed (the free default): a Code: [P]Code: 127.0.0.1:3100Day-to-day commands Code: systemctl restart nodeapp # after you change the code
journalctl -u nodeapp -n 50 --no-pager # the app's output and errors
systemctl stop nodeapp # stop it
systemctl disable --now nodeapp # stop it and don't start at bootCode: journalctlCode: console.logGood to know
Questions, or an app that won't start? Reply below with the lines from Code: journalctl -u nodeapp |