Actually yeah I've managed to install it in a subdirectory and run it via normal command line but I've got problems trying to get it to restart on reboot.
nginx/site-available/nodebb
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location /forum {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:4567/forum;
proxy_redirect off;
# Socket.IO Support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
config.json
{
"url": "http://localhost:4567/forum",
"secret": "insert_your_secret_here",
"database": "redis",
"redis": {
"host": "127.0.0.1",
"port": "6379",
"password": "insert_your_password_here",
"database": "0"
}
}
In order to restart nodebb upon server restart I've used the init script based on
https://www.exratione.com/2013/02/nodejs-and-forever-as-a-service-simple-upstart-and-init-scripts-for-ubuntu/
Modifications/Important config below
SOURCE_DIR="/var/www/nodebb"
NODE_USER="nodejs_user";
APPLICATION_PATH="app.js"
# ... other config
start() {
echo "Starting $NAME"
# sample forever command didn't seem to work
# forever
# --pidFile $PIDFILE
# -a
# -l $LOGFILE
# --minUptime $MIN_UPTIME
# --spinSleepTime $SPIN_SLEEP_TIME
# start $APPLICATION_PATH 2>&1 > /dev/null &
sudo -u $NODE_USER relative_path=/forum upload_url=/forum/uploads/ forever --sourceDir $SOURCE_DIR --pidFile $PIDFILE -a -l $LOGFILE --minUptime $MIN_UPTIME --spinSleepTime $SPIN_SLEEP_TIME start $APPLICATION_PATH 2>&1 > /dev/null &
Not sure if that's the best way of doing it, but it seemed to work for me.
Edit: Seems that file/image upload is broken: it uploads to /uploads/ instead of /forum/uploads/. Still looking into that
Edit 2: Uploads fixed with relative_path=/forum upload_url=/forum/uploads/ in the script. Other problems found:
- Can't stop forever via script (maybe something to do with log and pidfiles not being created)
- Can't install plugins
- Doesn't read from config.json but via environment variables passed in the init/forever script?