Want more timely Centmin Mod News Updates?
Become a Member

NodeBB Can't start NodeBB

Discussion in 'Forum software usage' started by BLM, Mar 24, 2018.

  1. BLM

    BLM New Member

    18
    2
    3
    Jun 24, 2017
    Ratings:
    +3
    Local Time:
    6:25 PM
    Hi, i'm using CentminMod since a year now.

    Today i tried to install a NodeBB Forum into a sub-directory of a website (like mydomain.com/forum) but didn't worked... I tought was something like a conflict because of sub-directory, so i did a new nginx vhost (forum.mydomain.com) and tried to install here, but same problem.

    I do every step without a problem, but in the last step i get this error message when i try to restart nginx:

    Code:
    Mar 24 01:59:09 systemd[1]: Starting SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server...
    Mar 24 01:59:09nginx[25134]: Starting nginx: nginx: [emerg] duplicate location "/" in /home/nginx/domains/forum.CENSORED.CENS/include-nodebb.conf:5
    Mar 24 01:59:09 nginx[25134]: [FAILED]
    Mar 24 01:59:09 systemd[1]: nginx.service: control process exited, code=exited status=1
    Mar 24 01:59:09 systemd[1]: Failed to start SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server.
    Mar 24 01:59:09 systemd[1]: Unit nginx.service entered failed state.
    Mar 24 01:59:09 systemd[1]: nginx.service failed.
    if i comment out the line:
    /home/nginx/domains/newdomain.com/include-nodebb.conf

    from:
    /usr/local/nginx/conf/conf.d/CENSORED.ssl.conf

    Nginx start but naturally NodeBB doesn't work.
    It's like 5 hours that i try to understand why i get that error without any results. Can you give me an hand? Thanks

    EDIT: after a while the server is running without the line i was talking about, i get this error:
    Code:
    [02:12][root@vsdasdasdasd nodebb]# events.js:183
          throw er; // Unhandled 'error' event
          ^
    
    Error: write after end
        at writeAfterEnd (_stream_writable.js:236:12)
        at LogStream.Writable.write (_stream_writable.js:287:5)
        at Socket.ondata (_stream_readable.js:639:20)
        at emitOne (events.js:116:13)
        at Socket.emit (events.js:211:7)
        at addChunk (_stream_readable.js:263:12)
        at readableAddChunk (_stream_readable.js:250:11)
        at Socket.Readable.push (_stream_readable.js:208:10)
        at Pipe.onread (net.js:607:20)
     
    Last edited: Mar 24, 2018
  2. eva2000

    eva2000 Administrator Staff Member

    33,704
    7,465
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,476
    Local Time:
    2:25 AM
    Nginx 1.13.x
    MariaDB 5.5
  3. BLM

    BLM New Member

    18
    2
    3
    Jun 24, 2017
    Ratings:
    +3
    Local Time:
    6:25 PM
    The one you linked, since it's the only one guide i found... Can you do an updated version?
     
  4. eva2000

    eva2000 Administrator Staff Member

    33,704
    7,465
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,476
    Local Time:
    2:25 AM
    Nginx 1.13.x
    MariaDB 5.5
    Unfortunately, no spare time right now. So you'd have to figure it out yourself.
     
  5. BLM

    BLM New Member

    18
    2
    3
    Jun 24, 2017
    Ratings:
    +3
    Local Time:
    6:25 PM
    I understand... Anyway, after a while i made it works, when i was doing my tests i wrote down every passage so at the end i did like a "Guide", can you give it a look? I have some dubts at the part:
    --- Create Nginx Config for NodeBB, subdirectory "Forum"

    I'm not an Nginx expert so i don't know if when i changed these line:
    "location ~ ^/" to "location ~ ^/forum/", and
    "location /" to "location /forum/"

    these can be a trouble in the long way... For now everything works: create new user, login, create topics, posts, install plugins etc. But since i edited these directives for make everything works, i don't know if somewhere i created like 100 bugs :D

    Code:
    Note: change mydomain.com with the URL of your website. These instruction are tested:
    1) with a fresh Nginx Host (both blank or with wordpress)
    2) with only HTTPS activated
    3) objective is to install NodeBB under a subfolder of the domain (mydomain.com/forum)
    4) NodeBB Version: 1.8.1
    
    Made by BLM using this guide as base: https://community.centminmod.com/threads/centmin-mod-nginx-nodebb-forum-install.4009/
    In this guide i don't talk about how to install redis, because i had one already installed and i don't remember what commands i used, but i guess the ones into the original guide are ok.
    
    
    
    --- Download NodeBB
    cd /home/nginx/domains/mydomain.com/public
    git clone -b v1.8.1 https://github.com/NodeBB/NodeBB nodebb
    
    --- Install NodeBB
    cd /home/nginx/domains/mydomain.com/public/nodebb
    npm install
    ./nodebb setup
    
    NOTE:
    1) During install, set the domain path of the Forum (like https://www.mydomain.com/forum)
    2) Set "Redis" as database
    3) Let everything else as default
    
    --- Start NodeBB
    ./nodebb start
    
    --- Create Alias
    vi ~/.bashrc
    >>> [Add these at the end of file]
    alias nodebbstart='cd /home/nginx/domains/mydomain.com/public/nodebb/; ./nodebb start'
    alias nodebbstop='cd /home/nginx/domains/mydomain.com/public/nodebb/; ./nodebb stop'
    alias nodebbrestart='cd /home/nginx/domains/mydomain.com/public/nodebb/; ./nodebb restart'
    alias nodebblog='cd /home/nginx/domains/mydomain.com/public/nodebb/; ./nodebb log'
    <<< [Alias will work after the first reboot, so for now we will not use them]
    
    --- Add ports to config.json
    vi /home/nginx/domains/mydomain.com/public/nodebb/config.json
    >>> [Add this line after "database": "redis",]
    "port": ["4567", "4568", "4569"],
    <<<
    service nginx restart
    cd /home/nginx/domains/mydomain.com/public/nodebb/; ./nodebb restart
    
    --- Verify 3 node.js instances are listening on ports 4567, 4568, 4569
    netstat -lnpt | grep 45
    
    --- Edit Nginx Config for the domain
    vi /usr/local/nginx/conf/conf.d/mydomain.com.ssl.conf
    >>> [Add these before "Server" statement]
    upstream io_nodes {
       ip_hash;
       server 127.0.0.1:4567;
       server 127.0.0.1:4568;
       server 127.0.0.1:4569;
    }
    <<<
    
    --- Create Nginx Config for NodeBB, subdirectory "Forum"
    vi /home/nginx/domains/mydomain.com/include-nodebb.conf
    >>> [Insert these lines and save]
    location ~ ^/forum/(images|language|sounds|templates|uploads|vendor|src\/modules|nodebb\.min\.js|stylesheet\.css|admin\.css) {
        root /home/nginx/domains/mydomain.com/public/nodebb/public;
    }
    
    location /forum/{
        root /home/nginx/domains/mydomain.com/public/nodebb/public;
        # proxy_pass http://127.0.0.1:4567;
        proxy_pass http://io_nodes;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        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_redirect off;
    
        # Socket.IO Support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
    <<<
    
    --- Include custom Nginx Config to default Nginx domain Config
    vi /usr/local/nginx/conf/conf.d/mydomain.com.ssl.conf
    >>> [Add this line around the end of file, before "staticfiles.conf", that you must comment out]
    include /home/nginx/domains/mydomain.com/include-nodebb.conf;
    # include /usr/local/nginx/conf/staticfiles.conf;
    <<<
    service nginx restart
    cd /home/nginx/domains/mydomain.com/public/nodebb/; ./nodebb restart
    
    --- Create autostart Script and make it executable
    vi /home/nginx/domains/mydomain.com/StartNodeBB.sh
    >>> [Add these line and save]
    #! /bin/sh
    cd /home/nginx/domains/mydomain.com/public/nodebb/
    ./nodebb start
    <<<
    cd /home/nginx/domains/mydomain.com/
    chmod +x StartNodeBB.sh
    
    --- Edit Crontab to make the script executable at startup
    crontab -e
    >>> [Add this line at the start of file]
    @reboot /home/nginx/domains/mydomain.com/StartNodeBB.sh
    <<<
     
  6. Meirami

    Meirami Member

    52
    6
    8
    Dec 21, 2017
    Ratings:
    +19
    Local Time:
    7:25 PM
    I think it's better add new location than edit old.
     
..