Run two NodeBB forums in parallel on same server

  • I tried to run two NodeBB forums in parallel. And apparently they interfere with each other regarding CSRF tokens and SID.

    I setup two independ copies of NodeBB /opt/nodebb/tf1 (port 4567) and /opt/nodebb/tf2 (port 4568). Both are proxied through an Apache 2.4 server. The config file of the server looks like:

    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/html
            ProxyRequests off
            <Proxy *>
                    Order deny,allow
                    Allow from all
            RewriteEngine On
            RewriteCond %{REQUEST_URI}  ^/tf1/            [NC]
            RewriteCond %{QUERY_STRING} transport=websocket        [NC]
            RewriteRule /tf1/(.*)       ws://localhost:4567/tf1/$1 [P,L]
            ProxyPass /tf1/ http://localhost:4567/tf1/
            ProxyPassReverse /tf1/ http://localhost:4567/tf1/
            RewriteCond %{REQUEST_URI}  ^/tf2/            [NC]
            RewriteCond %{QUERY_STRING} transport=websocket        [NC]
            RewriteRule /tf2/(.*)       ws://localhost:4568/tf2/$1 [P,L]
            ProxyPass /tf2/ http://localhost:4568/tf2/
            ProxyPassReverse /tf2/ http://localhost:4568/tf2/

    Looking at the cookies I have, it seems to me that the express.sid cookie might be the culprit. Its path is set to / instead to either /tf1/ or /tf2/.

  • Definitely were the cookies. Digged in the code and found the problem in src/middleware/index.js. Created a pull request that fixes this problem:

  • @Dravere I tried this but it didn't seem to resolve the problem for me. I don't have the sites in sub-folders - I'm using different ports instead i.e 4567 and 4566

    I added the code here:



Looks like your connection to NodeBB was lost, please wait while we try to reconnect.