Took me a few days to get this figured. This is what I got working:
1st (failed) attempt was setting up a node.js app in CPanel as a folder under the domain. i.e. domainname.com/CMS. This would not route properly, no matter what I tried. Kept throwing 404s.
2nd (successful) was using a subdomain.
Three main steps:
- register a CNAME record on the domain for
cms.domainname.com
- Configure and Build a new nodejs application in CPanel
- Bob's your uncle
Register a CNAME
Make sure your domain is configured with a CNAME record pointing at cms.domainname.com
Configure and Build
CPanel - Domain config
Under CPanel domains click Create a New Domain

Configure your domain and save it

CPanel - Create and configure
- In the nodeJS software page, create a new application and set it

- Either checkout your code into the root directory configured above or build locally and
ftp the build artifacts later.
The file structure of your folder on the server should look like this:
cms.domainname.com/
├── dist/ // build folder
└── server.js
└── package.json
└── .env
server.js
const strapi = require("@strapi/strapi");
// if you want logging enabled ...
// uncomment and see instructions section below
// const logger = require("./dist/config/logger");
const app = strapi({ distDir: "./dist" });
app.start();
.env
HOST=0.0.0.0 // might want to use the static IP address here. Don't know. Haven't tested it
PORT=3000
JWT_SECRET=
ADMIN_JWT_SECRET=
APP_KEYS=
API_TOKEN_SALT=
TRANSFER_TOKEN_SALT=
EXTERNAL_URL=https://cms.domainname.com
DATABASE_CLIENT=mysql
DATABASE_HOST=cms-mysql
DATABASE_PORT=3306
DATABASE_NAME=cms
DATABASE_USERNAME=root
DATABASE_PASSWORD=
DATABASE_SSL= false
package.json
Just make sure it has the latest npm packages and the standard script commands:
scripts": {
"dev": "strapi develop",
"start": "strapi start",
"build": "strapi build",
"strapi": "strapi"
},
Logging (optional)
If you want logging enabled:
- install loggig package
winston : npm i winston
- edit/add a file to
./config/logger.ts with the following:
"use strict";
import winston, { level, transports } from "winston";
export default {
level: "debug",
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports: [
new transports.Console({ level: "http" }),
new transports.File({ filename: "http.log", level: "http" }),
new transports.File({ filename: "debug.log", level: "debug" }),
new transports.File({ filename: "warn.log", level: "warn" }),
new transports.File({ filename: "error.log", level: "error" }),
new transports.File({ filename: "combined.log" }),
],
};
Build (through ssh)
- install packages:
npm i --omit=dev
- build:
npm run build
note: you need to rebuild every time you make a change to the code OR the `.env` file.
That should do it. You might need to access the application through the CPanel nodejs application dashboard and explicitly start it through the UI.