Change user running nodebb & other startup issues
-
Hi, I've just created my forum at bb.n66.pl using the following setup:
- architecture: arm64 VPS (netcup.de)
- OS: Ubuntu 22.04
- database: Mongodb 7.05
- proxy: NginX as automatically provided by Webinoly
- location: /home/user/nodebb
- coexisting software: WordPress installed using the Webinoly script
Nodebb seems to be working fine and I like it. A big thank you for making it available. But I'm not sure if it's safe running it as a user with sudo privileges. I think I should have created an unprivileged user and set up nodebb as such, which leads me to the following:
Question 1: Would it be OK to change ownership of the entire nodebb directory and its content at this moment when the forum is already set up?
Question 2: I'm starting nodebb with./nodebb start
, but I'm unable to get systemd to start it. I tried snippets (with relevant adjustments for the user and nodebb location) from nodebb docs and other web resources, but they lead to startup failure, or a bad gateway error. Can somebody publish a systemd unit that's actually working? -
We recommend running NodeBB under an unprivileged user. There shouldn't be a problem with chown/chmoding the files directly, but you could always make a copy first instead.
-
This works for me on Debian 12.
/etc/systemd/system/nodebb.service
[Unit] Description=NodeBB Documentation=https://docs.nodebb.org After=system.slice multi-user.target mongod.service [Service] Type=forking User=<USER> StandardOutput=syslog StandardError=syslog SyslogIdentifier=nodebb WorkingDirectory=/home/<USER>/nodebb PIDFile=/home/<USER>/nodebb/pidfile ExecStart=/usr/bin/node loader.js Restart=always [Install] WantedBy=multi-user.target
-
Thank you for your answers. I'll be trying these changes later today and will report back.
-
try to use PM2 https://pm2.keymetrics.io
-
@PitaJ said in Change user running nodebb & other startup issues:
There shouldn't be a problem with chown/chmoding the files directly, but you could always make a copy first instead.
Yes, there is a problem. I probably need to make some other changes besides chowning the nodebb directory and files, but I don't know what. I get the following errors
nodebb@sv:/home/homeuser/nodebb$ ./nodebb start node:internal/modules/cjs/loader:1147 throw err; ^ Error: Cannot find module '/home/homeuser/nodebb/nodebb' at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15) at Module._load (node:internal/modules/cjs/loader:985:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) at node:internal/main/run_main_module:28:49 { code: 'MODULE_NOT_FOUND', requireStack: [] } Node.js v20.11.0
-
@Jakub-Urbanowicz
After reverting ownership to homeuser the forum starts correctly. -
Changing the user is hard. Perhaps I will remove privileges from the existing user instead.
-
You should probably move the NodeBB files out of
homeuser
'shome
if You're not planning on homeuser running it. -
@PitaJ said in Change user running nodebb & other startup issues:
You should probably move the NodeBB files out of homeuser's home if You're not planning on homeuser running it.
Yeah, seems so. Could you give me a gist of what steps I would need to take to move nodebb to e.g. /var/www, please?
-
@B-738 said in Change user running nodebb & other startup issues:
try to use PM2 https://pm2.keymetrics.io
PM2 does much more than just start an app. Do you think I will need to change NginX proxy settings if I start nodebb with it? What if I increase the number of workers with pm2 scale app x?
-
@Jakub-Urbanowicz said in Change user running nodebb & other startup issues:
@PitaJ said in Change user running nodebb & other startup issues:
You should probably move the NodeBB files out of homeuser's home if You're not planning on homeuser running it.
Yeah, seems so. Could you give me a gist of what steps I would need to take to move nodebb to e.g. /var/www, please?
mv /home/user/nodebb /var/www/nodebb
-
@Jakub-Urbanowicz I recomend to all use Caddy web server instead of Nginx ! Much better and simple , also be default use SSL (https) and do automatic update of ssl from letencrupt
OS FreeBSD
DataBase MongoDB
NodeJS NPM
PM2
Best proxy SSL server Caddy
GoLang -