NodeBB est un moteur de forum moderne Open Source sous licence GPLv3, développé en Javascript via Node.js et utilisant Redis (ou MongoDB, au choix) comme système de gestion de bases de données NoSQL. Grâce à Node.js, les actions sont exécutées plus rapidement qu’avec PHP, et grâce à Redis et le chargement des données en RAM, les requêtes se font de manière très performante. NodeBB est né en 2013 et est développé par la société Design Create Play basée à Toronto au Canada. Sa version actuelle est la 1.4.5.
Alternatives Open Source à NodeBB :
Comparatif de certaines de ces solutions à cette adresse.
Objectif
L’objectif de cet article est l’installation et la configuration d’un serveur auto-hébergé NodeBB, sur serveur Web Node.js et base de données Redis, en version 1.4.5 sur une distribution Linux Debian Jessie 8.7 32bits.
Schéma logique

Pré-requis
1. Pré-requis avant réalisation
- Un serveur Debian Jessie 8.7 32 bits fonctionnel (installation basique avec utilitaires usuels du système et service SSH)
- Packages de base supplémentaires : sudo, resolvconf, tree
- Domaine utilisé : opensharing.priv
2. Configuration réseau initiale
Serveur NodeBB | |
FQDN | nodebb-test.opensharing.priv |
Adresse IP | 192.168.1.25 |
Réseau | 192.168.1.0/24 |
Passerelle | 192.168.1.1 |
dns-nameservers | 192.168.1.11 192.168.1.12 |
dns-search | opensharing.priv |
Contenu initial du fichier /etc/network/interfaces :
auto lo iface lo inet loopback allow-hotplug eth0 iface eth0 inet static address 192.168.1.25 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 dns-search opensharing.priv dns-nameservers 192.168.1.11 192.168.1.12
Contenu initial du fichier /etc/hosts :
127.0.0.1 localhost.localdomain localhost 192.168.1.25 nodebb-test.opensharing.priv nodebb-test 192.168.1.25 nodebb.opensharing.priv nodebb
Rmq : L’adresse 127.0.1.1 doit être retirée sur un serveur à IP fixe et remplacée par cette dernière, tel que l’exemple ci-dessus.
Contenu initial du fichier /etc/host.conf :
order hosts, bind multi on
Contenu initial du fichier /etc/resolv.conf :
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 192.168.1.11 nameserver 192.168.1.12 search opensharing.priv
Rmq :
Le fichier /etc/resolv.conf ne doit pas être édité dès lors que le paquet resolvconf a été installé.
Pour prendre en compte les modifications des fichiers de configuration relatifs au réseau, redémarrage du service réseau :
# /etc/init.d/networking restart # /etc/init.d/networking reload
Réalisation
1. Installation de paquets complémentaires
# apt install git build-essential imagemagick curl
Installe les paquets suivants par dépendances :
curl | git | git-man | libcurl3 |
liberror-perl | rsync |
2. Installation de Node.js
Node.js est utilisé sur NodeBB comme serveur Web. Il est possible d’installer Apache ou Nginx comme reverse proxy redirigeant les requêtes vers le serveur Web Node.js. C’est ce que nous verrons dans la section Pour aller plus loin.
Ce serveur web utilise, par défaut, le port 4567.
# curl -sL https://deb.nodesource.com/setup_7.x | bash -
Installe le dépôt Node.js v7.x en suivante les étapes suivantes :
# apt-get install -y apt-transport-https > /dev/null 2>&1
# curl -sLf -o /dev/null ‘https://deb.nodesource.com/node_7.x/dists/jessie/Release’
# curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add –
# echo ‘deb https://deb.nodesource.com/node_7.x jessie main’ > /etc/apt/sources.list.d/nodesource.list
# echo ‘deb-src https://deb.nodesource.com/node_7.x jessie main’ >> /etc/apt/sources.list.d/nodesource.list
# apt-get update
# apt install -y nodejs
Installe Node.js en version 7.9.0 et npm en version 4.2.0.
3. Installation de Redis
Le serveur Redis est utilisé sur NodeBB comme moteur de base de données, un SGBD key-value NoSQL, permettant par le chargement en RAM des données d’atteindre de hautes performances.
Il est possible d’utiliser MongoDB comme moteur de base de données, un SGBD orienté documents NoSQL, performant également mais probablement moins que Redis, c’est pourquoi nous choisirons la première option. Redis Server utilise par défaut le port 6379 (et MongoDB le port 27017).
# apt install redis-server
Installe les paquets suivants par dépendances :
libjemalloc1 | redis-server | redis-tools |
4. Installation de NodeBB
# mkdir /opt/nodebbdir/ && cd $_ # git clone https://github.com/NodeBB/NodeBB.git . . Clonage dans '.'... remote: Counting objects: 127071, done. remote: Compressing objects: 100% (8/8), done. remote: Total 127071 (delta 2), reused 2 (delta 2), pack-reused 127061 Réception d'objets: 100% (127071/127071), 38.79 MiB | 766.00 KiB/s, fait. Résolution des deltas: 100% (96266/96266), fait. Vérification de la connectivité... fait.
# npm install --production
# ./nodebb setup 15/4 00:35:54 [7503] - info: NodeBB Setup Triggered via Command Line Welcome to NodeBB! This looks like a new installation, so you'll have to answer a few questions about your environment before we can proceed. Press enter to accept the default setting (shown in brackets). URL used to access this NodeBB (http://localhost:4567) http://nodebb.opensharing.priv:4567 Please enter a NodeBB secret (95c38e53-aae3-49ba-9caf-3926e12f02b4) Which database to use (mongo) redis 15/4 00:36:15 [7503] - info: Now configuring redis database: Host IP or address of your Redis instance (127.0.0.1) Host port of your Redis instance (6379) Password of your Redis database Which database to use (0..n) (0) Configuration Saved OK Populating database with default configs, if not already set... 15/4 00:36:35 [7503] - warn: [cache-buster] could not read cache buster: ENOENT: no such file or directory, open '/opt/nodebbdir/build/cache-buster' Enabling default theme: nodebb-theme-persona No categories found, populating instance with default categories 15/4 00:36:35 [7503] - warn: No administrators have been detected, running initial user setup Administrator username nodebbadmin Administrator email address admin@opensharing.priv Password Confirm Password Creating welcome post! Enabling default plugins 15/4 00:37:14 [7503] - info: [install/defaultPlugins] customDefaults 15/4 00:37:14 [7503] - info: [install/enableDefaultPlugins] activating default plugins 0=nodebb-plugin-composer-default, 1=nodebb-plugin-markdown, 2=nodebb-plugin-mentions, 3=nodebb-widget-essentials, 4=nodebb-rewards-essentials, 5=nodebb-plugin-soundpack-default, 6=nodebb-plugin-emoji-extended, 7=nodebb-plugin-emoji-one 15/4 00:37:14 [7503] - info: Beginning database schema update 15/4 00:37:14 [7503] - info: [2016/09/22] Setting category recent tids - skipped! 15/4 00:37:14 [7503] - info: [2016/10/8] favourite -> bookmark refactor - skipped! 15/4 00:37:14 [7503] - info: [2016/10/14] Creating sorted sets for post replies - skipped! 15/4 00:37:14 [7503] - info: [2016/11/22] Update global and user language keys - skipped! 15/4 00:37:14 [7503] - info: [2016/11/25] Creating sorted sets for pinned topics - skipped! 15/4 00:37:14 [7503] - info: [2017/2/25] Update global and user sound settings - skipped! 15/4 00:37:14 [7503] - info: [2017/2/28] Update urls in config to `/assets` - skipped! 15/4 00:37:14 [7503] - info: [upgrade] Schema already up to date! 15/4 00:37:14 [7503] - info: [build] Building javascript WARN: Output exceeds 32000 characters WARN: Output exceeds 32000 characters WARN: Output exceeds 32000 characters WARN: Output exceeds 32000 characters WARN: Output exceeds 32000 characters 15/4 00:37:35 [7503] - info: [build] js => Completed in 20.637s 15/4 00:37:35 [7503] - info: [build] Building client-side CSS 15/4 00:37:41 [7503] - info: [build] clientCSS => Completed in 6.172s 15/4 00:37:41 [7503] - info: [build] Building admin control panel CSS 15/4 00:37:47 [7503] - info: [build] acpCSS => Completed in 5.489s 15/4 00:37:47 [7503] - info: [build] Building templates 15/4 00:37:47 [7503] - info: [build] tpl => Completed in 0.295s 15/4 00:37:47 [7503] - info: [build] Building language files 15/4 00:37:59 [7503] - info: [build] lang => Completed in 11.633s 15/4 00:37:59 [7503] - info: [build] Linking sound files 15/4 00:37:59 [7503] - info: [build] sound => Completed in 0.003s 15/4 00:37:59 [7503] - info: [build] Asset compilation successful. Completed in 44.367s. ======================================================================================================================= NodeBB Setup Completed. Run './nodebb start' to manually start your NodeBB server.
Ce script crée automatiquement le serveur Web Node.js http://nodebb.opensharing.priv , la base de données Redis d’indice 0 et l’administrateur du forum nodebbadmin.
# ./nodebb start Starting NodeBB "./nodebb stop" to stop the NodeBB server "./nodebb log" to view server output "./nodebb restart" to restart NodeBB
5. Première connexion au forum NodeBB
Se connecter à l’URL suivant :
http://nodebb.opensharing.priv:4567
L’interface Web du forum s’affiche.
Cliquer sur Login pour s’authentifier.
L’interface du forum NodeBB après authentification s’affiche.
Ainsi que l’accès aux paramètres de l’utilisateur nodebbadmin.
Ou encore le tableau d’administration réservé à l’administrateur nodebbadmin.
Ci-dessus, le tableau de bord de l’administrateur après modification de la langue vers le français.
Pour aller plus loin
1. Utiliser Apache en HTTPS et comme reverse Proxy

# cd /opt/nodebbdir/ # ./nodebb stop # nano config.json
Les 3 lignes en gras doivent être présentes :
{ "url": "http://nodebb.opensharing.priv:4567", "secret": "95c38e53-aae3-49ba-9caf-3926e12f02b4", "port": "4567", "use_port": false, "bind_address": "127.0.0.1", "database": "redis", "redis": { "host": "127.0.0.1", "port": "6379", "password": "", "database": "0" } }
# apt install apache2 apache2-doc # mkdir /var/www/nodebb/ # nano /etc/apache2/sites-available/nodebb.conf
<VirtualHost *:80> DocumentRoot /var/www/nodebb/ ServerName nodebb.opensharing.priv Redirect permanent / https://nodebb.opensharing.priv/ </VirtualHost> <VirtualHost *:443> DocumentRoot /var/www/nodebb/ ServerName nodebb.opensharing.priv <Directory /var/www/nodebb/> Options +FollowSymlinks AllowOverride All </Directory> SetEnv HOME /var/www/nodebb SetEnv HTTP_HOME /var/www/nodebb ErrorLog /var/log/apache2/nodebb.error.log CustomLog /var/log/apache2/nodebb.log combined SSLEngine On SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire SSLCertificateFile /etc/ssl/certs/nodebbperso.crt SSLCertificateKeyFile /etc/ssl/private/nodebbperso.key ProxyRequests off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass /socket.io/1/websocket ws://127.0.0.1:4567/socket.io/1/websocket ProxyPassReverse /socket.io/1/websocket ws://127.0.0.1:4567/socket.io/1/websocket ProxyPass /socket.io/ http://127.0.0.1:4567/socket.io/ ProxyPassReverse /socket.io/ http://127.0.0.1:4567/socket.io/ ProxyPass / http://127.0.0.1:4567/ ProxyPassReverse / http://127.0.0.1:4567/ </VirtualHost>
Génération de la clef privée :
# openssl genrsa -out /etc/ssl/private/nodebbperso.key 1024
Generating RSA private key, 1024 bit long modulus
.................................................................++++++
..............++++++
e is 65537 (0x10001)
Demande de certificat à partir de la clef :
# openssl req -new -key /etc/ssl/private/nodebbperso.key -out /etc/ssl/certs/nodebbperso.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank. For some fields there will be a default value, if you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:FR State or Province Name (full name) [Some-State]:Ile-de-France Locality Name (eg, city) []:Paris Organization Name (eg, company) [Internet Widgits Pty Ltd]:OpenSharing Organizational Unit Name (eg, section) []:Service Informatique Common Name (e.g. server FQDN or YOUR name) []:nodebb.opensharing.priv Email Address []:admin@opensharing.priv Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []:nodebbcertificate An optional company name []:OpenSharing
Construction du certificat :
# openssl x509 -req -days 365 -in /etc/ssl/certs/nodebbperso.csr -signkey /etc/ssl/private/nodebbperso.key -out /etc/ssl/certs/nodebbperso.crt Signature ok subject=/C=FR/ST=Ile-de-France/L=Paris/O=OpenSharing/OU=Service Informatique/CN=nodebb.opensharing.priv/emailAddress=admin@opensharing.priv Getting Private key
# a2ensite nodebb # a2enmod rewrite # a2enmod ssl # a2enmod proxy # a2enmod proxy_http # a2enmod proxy_wstunnel # apachectl configtest Syntax OK # service apache2 restart # cd /opt/nodebbdir/ # ./nodebb start
2. Utiliser Nginx en HTTPS et comme reverse Proxy

# cd /opt/nodebbdir/ # ./nodebb stop # nano config.json
Les 3 lignes en gras doivent être présentes :
{ "url": "http://nodebb.opensharing.priv:4567", "secret": "95c38e53-aae3-49ba-9caf-3926e12f02b4", "port": "4567", "use_port": false, "bind_address": "127.0.0.1", "database": "redis", "redis": { "host": "127.0.0.1", "port": "6379", "password": "", "database": "0" } }
# apt install nginx
# nano /etc/nginx/conf.d/nodebb.conf
server { listen 80; server_name nodebb.opensharing.priv; # enforce https return 301 https://$server_name$request_uri; } server { listen 443 ssl; server_name nodebb.opensharing.priv; ssl_certificate /etc/ssl/certs/nodebbperso.crt; ssl_certificate_key /etc/ssl/private/nodebbperso.key; location / { 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/; proxy_redirect off; # Socket.IO Support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }
Construction du certificat :
# openssl genrsa -out /etc/ssl/private/nodebbperso.key 1024
Generating RSA private key, 1024 bit long modulus
.................................................................++++++
..............++++++
e is 65537 (0x10001)
Demande de certificat à partir de la clef :
# openssl req -new -key /etc/ssl/private/nodebbperso.key -out /etc/ssl/certs/nodebbperso.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank. For some fields there will be a default value, if you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:FR State or Province Name (full name) [Some-State]:Ile-de-France Locality Name (eg, city) []:Paris Organization Name (eg, company) [Internet Widgits Pty Ltd]:OpenSharing Organizational Unit Name (eg, section) []:Service Informatique Common Name (e.g. server FQDN or YOUR name) []:nodebb.opensharing.priv Email Address []:admin@opensharing.priv Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []:nodebbcertificate An optional company name []:OpenSharing
Construction du certificat :
# openssl x509 -req -days 365 -in /etc/ssl/certs/nodebbperso.csr -signkey /etc/ssl/private/nodebbperso.key -out /etc/ssl/certs/nodebbperso.crt Signature ok subject=/C=FR/ST=Ile-de-France/L=Paris/O=OpenSharing/OU=Service Informatique/CN=nodebb.opensharing.priv/emailAddress=admin@opensharing.priv Getting Private key
Vérification de la syntaxe de la configuration de Nginx :
# nginx -tc /etc/nginx/nginx.conf
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# service nginx restart # cd /opt/nodebbdir/ # ./nodebb start
3. Effectuer une sauvegarde manuelle complète
# cd /opt/nodebbdir/ # ./nodebb stop # service redis-server stop # mkdir -p /home/adminsys/backup/1.4.5/ # cd /home/adminsys/backup/1.4.5/ # tar -czvf backup-nodebb-20170415.tar.gz -C /opt/ nodebbdir/ # cp -a /var/lib/redis/dump.rdb /home/adminsys/backup/1.4.5/ # service redis-server start # cd /opt/nodebbdir/ # ./nodebb start
4. Effectuer une restauration manuelle complète
# cd /opt/nodebbdir/ # ./nodebb stop # service redis-server stop # cd /home/adminsys/backup/1.4.5/ # tar -xzvf backup-nodebb-20170415.tar.gz -C /opt/ # cp -a /home/adminsys/backup/1.4.5/dump.rdb /var/lib/redis/ # service redis-server start # cd /opt/nodebbdir/ # ./nodebb start # service nginx restart
5. Effectuer un upgrade de NodeBB
# cd /opt/nodebbdir/ # git pull https://github.com/NodeBB/NodeBB.git
Références
- NodeBB Site Officiel
- NodeBB Documentation Officielle
- NodeBB Supervisor et Forever
- GitHub – Depôt de NodeBB
- Redis Server – Commandes
- Node.js – Site Officiel
- Node.js – Installation
- Supervisor
- Forever