NodeBB on Nginx

Install and configure NodeBB forum software with Centmin Mod Nginx reverse proxy.

Overview

NodeBB is a modern, real-time forum platform built on Node.js. Since NodeBB runs its own HTTP server, Centmin Mod's Nginx is configured as a reverse proxy to forward requests to the NodeBB application backend.

How It Works

Unlike PHP applications, NodeBB runs as a standalone Node.js process. Nginx acts as a reverse proxy, forwarding HTTP requests to the NodeBB process (typically on port 4567) while handling SSL termination, static file serving, and connection management.

1

Prerequisites

Before installing NodeBB, ensure you have the following components installed:

  • Node.js — NodeBB requires a supported LTS version of Node.js. Install via the Centmin Mod addons or manually from the official Node.js site.
  • Redis or MongoDB — NodeBB uses either Redis or MongoDB as its data store. Redis is recommended for most installations and can be installed via Centmin Mod addons.
  • Centmin Mod LEMP — A working Centmin Mod installation with Nginx. Follow the Getting Started guide.
2

Install Node.js

Install Node.js using the NodeSource repository:

curl -fsSL https://rpm.nodesource.com/setup_lts.x | bash -
yum install -y nodejs
node -v
npm -v
3

Install Redis

Install Redis as the data store for NodeBB:

yum install -y redis
systemctl start redis
systemctl enable redis
redis-cli ping

The redis-cli ping command should return PONG if Redis is running correctly.

4

Install NodeBB

Clone the NodeBB repository and run the setup:

cd /home/nginx/domains
git clone -b v3.x https://github.com/NodeBB/NodeBB.git nodebb
cd nodebb
./nodebb setup

During setup, NodeBB will ask for configuration details including the URL, port (default 4567), and database backend (Redis or MongoDB). After setup completes, start NodeBB:

./nodebb start
5

Nginx Reverse Proxy Configuration

Create an Nginx vhost configuration that proxies requests to the NodeBB Node.js process. Create or edit the vhost config file (e.g., /usr/local/nginx/conf/conf.d/forum.yourdomain.com.conf):

server {
  listen 80;
  server_name forum.yourdomain.com;

  access_log /home/nginx/domains/forum.yourdomain.com/log/access.log combined buffer=256k flush=5m;
  error_log /home/nginx/domains/forum.yourdomain.com/log/error.log;

  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";
  }
}

WebSocket Support

The proxy_http_version 1.1 and Upgrade headers are essential for NodeBB's real-time features via Socket.IO/WebSockets.

With SSL (HTTPS)

For SSL-enabled configurations, add an HTTPS server block. Set up your SSL certificate first per the Let's Encrypt Free SSL guide:

server {
  listen 80;
  server_name forum.yourdomain.com;
  return 301 https://$server_name$request_uri;
}

server {
  listen 443 ssl http2;
  server_name forum.yourdomain.com;

  ssl_certificate /usr/local/nginx/conf/ssl/forum.yourdomain.com/fullchain.pem;
  ssl_certificate_key /usr/local/nginx/conf/ssl/forum.yourdomain.com/privkey.pem;
  ssl_protocols TLSv1.2 TLSv1.3;
  ssl_prefer_server_ciphers on;

  access_log /home/nginx/domains/forum.yourdomain.com/log/access.log combined buffer=256k flush=5m;
  error_log /home/nginx/domains/forum.yourdomain.com/log/error.log;

  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";
  }
}
6

Restart Nginx and Verify

Test the Nginx configuration and restart:

nginx -t
ngxrestart

Visit forum.yourdomain.com in your browser. You should see the NodeBB forum interface. If the page does not load, ensure the NodeBB process is running (./nodebb status) and check the Nginx error log.

Process Management

NodeBB provides built-in commands for managing the process:

./nodebb start     # Start NodeBB
./nodebb stop      # Stop NodeBB
./nodebb restart   # Restart NodeBB
./nodebb status    # Check if NodeBB is running
./nodebb log       # View NodeBB logs

For production use, consider running NodeBB with a process manager like pm2 or a systemd service unit to ensure it restarts automatically after server reboots.

Related Pages