Hello All,
this is a guideline of how to get NodeBB running on Windows in a way which worked for me.
I will update this guideline over time as there is always something to improve.
Prerequisites Stuff
These steps have been captured by a new VPS installation.
The following was installed before attempting the steps further below:
- Windows Server 2016 / Windows 10 (tested on both)
- Full Windows Update
- Visual Studio Code Insider
- Visual Studio Community Edition 15.7.1 (C++ and .NET Environments)
Download Stuff
Node.js
https://nodejs.org/dist/v10.1.0/node-v10.1.0-x64.msi
nginx
https://nginx.org/download/nginx-1.14.0.zip
MongoDB
https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-3.6.4-signed.msi
NodeBB
https://codeload.github.com/NodeBB/NodeBB/zip/v1.9.1
Install Stuff
Install Node.js > X:\Node
Unzip nginx > X:\nginx
Unzip NodeBB > X:\NodeBB
Install Mongo > X:\MongoDB
Test Stuff
Test Node.js
cmd > node --version
v10.1.0
Test nginx
cmd > X:\nginx
nginx -v
nginx version: nginx/1.14.0
Test Mongo
Add to Path (User & System) > X:\MongoDB\bin
Reboot
cmd > mongod --version
db version v3.6.4
Configure Mongo Service Stuff
mkdir X:\MongoDB\data\db
mkdir X:\MongoDB\logs
make a file called mongod.cfg:
systemLog:
destination: file
path: X:\MongoDB\logs\mongod.log
storage:
dbPath: X:\MongoDB\data\db
security:
authorization: enabled
copy mongod.cfg > X:\MongoDB\mongod.cfg
Install Mongo as Windows Service
sc.exe create MongoDB binPath= ""X:\MongoDB\bin\mongod.exe" --service --config="X:\MongoDB\mongod.cfg"" DisplayName= "MongoDB" start= "auto"
[SC] CreateService SUCCESS
net start MongoDB
The MongoDB service is starting.
The MongoDB service was started successfully
InfoBox
How to Remove Mongo as Windows Service
net stop MongoDB
sc.exe delete MongoDB
Create Mongo Database Stuff
Create 2 very good long safe uncrackable passwords:
PASSWORD1 > MondoDB Admin
PASSWORD2 > MongoDB NodeBB Account
cmd > mongo
use admin
db.createUser( { user: "admin", pwd: "PASSWORD1", roles: [ { role: "readWriteAnyDatabase", db: "admin" }, { role: "userAdminAnyDatabase", db: "admin" } ] } )
Look for something like:
"Successfully added user"
quit()
net stop MongoDB
net start MongoDB
mongo -u admin -p PASSWORD1 --authenticationDatabase=admin
use nodebb
db.createUser( { user: "nodebb", pwd: "PASSWORD2", roles: [ { role: "readWrite", db: "nodebb" }, { role: "clusterMonitor", db: "admin" } ] } )
Look for something like:
"Successfully added user"
quit()
NodeBB Configuration Stuff
cmd > X:\NodeBB
nodebb setup
Wait for stuff to happen ..
Answers the prompts
Note: Set the URL to your real Yourdomain.com if you want to use one !
Or fix it later here:
X:\NodeBB\config.json
If you mess up, start again with:
nodebb setup
Check for:
"NodeBB Setup Completed"
Start the Forum
cmd > nodebb start
InfoBox
To Stop ..
nodebb stop
Node.js will start up
Access your forum at your Yourdomain:4567 (or localhost:4567 for testing)
nginx Stuffnx
Edit C:\nginx\conf\nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name 123.124.125.126;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:4567;
proxy_redirect off;
# Socket.IO Support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
}
make sure to edit ..
server_name 123.124.125.126;
.. with your real webserver external IP
InfoBox
Default value for the listening IP is:
server_name $hostname;
Which gets translated to 0.0.0.0 which means 'All IPs'
Ok, lets move on ..
start nginx
InfoBox
Good to know:
nginx -s stop
nginx -s restart
Access your forum at: Yourdomain:80
You want to further tune your nginx.conf by doing lots of Google research but it should work for now.
More Stuff
- Get extreme speeds by putting your X:\ in a Ramdisk
I recommend Softperfect Ramdisk as unlike other Windows ramdisks it has excellent performance on parallel read/write requests.
Currently I have Node.js/Mongo/nginx/NodeBB on a Ramdisk image with a size of 4GB, autosave every 60 minutes or any interval you need. Around 2.5GB are used for all having an empty forum.
-
Issues: I still investigate a problem with Mongo to cash overnight, will update once I figure that out.
-
Tuning: You do not really need to use nginx in this scenario. It all depends on your own website project. However nginx can offer some cache features and other magic things which you may want to use at some point.
-
Windows Firewall, if you can't connect to the forum from an external device, try to edit your Windows Firewall configuration for Port 80 to listen to your external IP only. If you set it to "All IP's" it did not work for me somehow.