Setup NodeBB with DigitalOcean and Nginx
Suppose you have a homepage site ‘www.xyz.com(xyz.com)’ is hosted by Github with Jekyll, but a few days later, you realized that you need a forum, such as ‘forum.xyz.com’ to post stuff within the community.
Here is what we need to do(high level):
- Setup NodeBB
- Configure Nginx on sever
- Configure subdomain to point to the server with NodeBB
Setup NodeBB
You can install NodeBB by following this tutorial along with the official document.
(Note: While installing NodeBB, you will be prompted with questions like Admin username or Admin password, don’t forget to set administrator info here).
You won’t need to do any customized configuration yet, just follow the steps i the tutorial, if everything is right, you should be seeing [your server’s IP address]:4567 with nodeBB.(say 192.123.222.111:4567, 4567 is the default port for nodeBB).
Configure Nginx
Typically you don’t want visitors to see the port, so let’s use nginx as a proxy.
Install Nginx
See tutorial here.
Remember you have to use a regular, non-root user with sudo
priviledges for this.
Configure Nginx
Update nginx.conf
This file is normally located in /etc/nginx
in Ubuntu.
Add a upstream section in http section like this:
Note, you might need to run sudo vim nginx.conf
instead of vi nginx.conf
due to potential permission issues.
Add conf file
Now let’s create a nodebb.conf
file in /etc/nginx/sites-enabled
with below content:
Test and Restart
Test the nginx config after changes(as root): nginx -t
and reload config: service nginx reload
Update Config.json in NodeBB
Lastly, you need to update config.json
in the root of nodeBB you just installed:
If everything looks fine, you should use forever tp run the script continuously. In your nodeBB root director: npm install -g forever
then forever start app.js
Also, you can install supervisor
to restart node app while debugging: npm install -g supervisor
and supervisor app
.
Setup Subdomain
The last step will be create a subdomain for this nodeBB forum.
Let’s point subdomain to another web hosting(digital ocean this time, instead of the homepage hosted by Github).
I use Godaddy for domain management, but I assume the steps are similar among other services.
In the setting page of www.xyz.com:
- click the DNS zone file tab
- click Add Record
- add a
A(host)
type record, the host is ‘forum.xyz.com’, points to your digitalocean server address. - save the change.
Give it a couple of minutes, and visit http://forum.xyz.com.