Installing NodeBB in a subfolder of another site

Technical Support
  • The guide given here is for installing NodeBB in a subdomain.

    What will be the changes that need to be made so that it can be accessed from a subfolder, like http://website.com/forum. I'm currently accessing it by appending the port number to the URL, but that will have to change before the site is made public.

    TIA.

  • @baris has been doing work for subfolder installs on and off over the past several months. The main problem is that we don't have any dedicated users with subforum installs so it is hard to find bugs.

  • During node app --setup you will have to put in the url of the forum like http://domain.com/forum the rest is business as usual. But as @julian said we haven't really tested everything with subfolder installations so if you happen to find any bugs let us know.

  • @julian

    My primary concern now is to get it to work. Installing it in a subdomain is not something I want to do, so any tips you can share will be very much appreciated.

  • @baris

    I tried that http://site.com/subfolder during a local install and the installation failed, that's why I didn't bother with passing that URL on the live site.

  • @baris

    Ok, so I tried a new local installation in a subfolder and here's what happened

    I can specify http://ip-address/subfolder during installation and answer n when asked if the application should connect via a port number. However, it seems that NodeBB is ignoring that, because of this output on starting it.

    info: Initializing NodeBB v0.3.0, on port 4567, using redis store at 127.0.0.1:6379.
    info: NodeBB instance bound to: Any address (0.0.0.0)
    info: Using ports 80 and 443 is not recommend; use a proxy instead. See README.md
    info: NodeBB Ready
    

    And if I navigate to http://ip-address/forum, I get redirected to http://ip-address:4567/forum

    Note that this is without messing with Nginx yet, but @baris, @julian, @psychobunny, what do you make of NodeBB ignoring the do-not-connect-via-port-number directive?

  • @planner What's your config.json? If you specified port 80 or 443 in the setup, it shouldn't fall back to using 4567...

  • @julian

    Well, I did not specify port 80 or 443, at least not explicitly. But I assume that by specifying http://ip-address/forum, I'm implicitly telling it to connect via whatever port the parent application is connecting to, which in this case, is 80.

  • And if I navigate to http://ip-address/forum, I get redirected to http://ip-address:4567/forum

    Hm, if you specified port 4567 in the setup, NodeBB does not listen on port 80, so I don't quite know why you got redirected when accessing /forum with no port. In any case, I've confirmed that NodeBB does listen on the port you specify during setup. If you have not set up the proxy yet, you will not be able to access your site without a port number...

  • @julian

    Here's my config.json:

    {
        "base_url": "http://192.168.1.4",
        "port": "4567",
        "use_port": false,
        "secret": "fff02b17-b9cc-444c-b929-85ec9cecec93",
        "bind_address": "0.0.0.0",
        "database": "redis",
        "redis": {
            "host": "127.0.0.1",
            "port": "6379",
            "password": "redis",
            "database": "0"
        },
        "bcrypt_rounds": 12,
        "upload_path": "/public/uploads",
        "relative_path": "/forum"
    

    It shows that even after telling it not to connect via port 4567, it still did anyway.

  • Actually, the use_port directive is more of a "if we need to construct a URL, use the port number in it". NodeBB will always listen on the port specified. Sorry for the confusion!

  • @julian

    Ok, thanks.

    Any clues how I can get it to connect properly, that is, via http://ip-address/forum?

  • You'll have to use a proxy... or start NodeBB using port 80 (which, as the warning suggests, is not recommended). You'll need root access to run NodeBB under port 80.

  • info: Using ports 80 and 443 is not recommend; use a proxy instead. See README.md

    not recommend

    recommend

    you can tell i'm arab

    edit: I added that warning.

  • Hahaha... Asians make those mistakes too. That's my official reason for not noticing the typo.

  • @julian

    I'm not an Arab or Asian and I didn't notice it. What's my excuse?

  • @baris, @julian, @psychobunny, I'm still on this.

    If I modify the code given here for the subfolder installation to look like this:

    upstream nodejs {
        server 192.168.1.4:4567;
    }
    
    server {
        listen 80;
    
        server_name 192.168.1.4:4567;
        root /var/www/forum;
    
        location /forum {
            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://192.168.1.4:4567;
            proxy_redirect off;
    
            # Socket.IO Support
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    }
    

    I get a 403 Forbidden error message when I attempt to access http://ip-address/forum.

    And if I replace server_name 192.168.1.4:4567; with server_name 192.168.1.4/forum;. nginx -t reports"

    nginx: [warn] server name "127.0.0.1/forum" has suspicious symbols in /etc/nginx/sites-enabled/default:91
    

    Note that NodeBB (nodejs) is listening on the default port, even though I didn't want it to.

    Any suggestions?

  • NodeBB has to listen on a port. It could listen on a UNIX socket, but that's outside of the scope of this question (and is pretty pointless, anyway).

    Given your nginx config, please make the following changes:

    • Remove the upstream portion, as you don't seem to be referencing it anymore
    • Remove the root directive, it is not required
    • server_name should be 192.168.1.4, no port

    nginx -t should work then, and you can restart it and try again.

    nginx: [warn] server name "127.0.0.1/forum" has suspicious symbols in /etc/nginx/sites-enabled/default:91

    If you still get this error, take a look at what's on line 91 of default..!

  • @julian

    I'm getting warmer. Here's what I did:

    I just added the code below into the default server block, that is, no separate server block for NodeBB.

    location ^~ /forum {
            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://192.168.1.4:4567;
            proxy_redirect off;
        }
    

    Navigated to http://ip-address/forum and got the default page, minus the default categories. And clicking on any of the buttons returns nothing. No error messages in the log files.

    I'll recircle back to the previous attempt, but what do you make of this?

    Here's a screenshot:

    NodeBBerror1.jpg

  • What shows up in the console tab of the chrome inspector? This will help @baris debug, if necessary


Suggested Topics


  • 0 Votes
    6 Posts
    575 Views

    @xinbenlv I think you can change this setting from Admin Control Panel... (or completely remove restriction)

  • 0 Votes
    1 Posts
    558 Views

    Hi.

    I'm currently using an Ubuntu server and I want to install Wordpress and NodeBB, for example:
    mydomain. com (Wordpress)
    forum.mydomain. com or mydomain. com/forum (NodeBB)

    I tried some things but failed. NodeBB need to be installed with Node.js and Wordpress with Apache or Nginx, but there are some conflincts when I'm using both.

    I've searched and read some topics but none helped me (not my situation or didn't understood them).

    Thanks for your help!

  • 0 Votes
    1 Posts
    541 Views

    Hello,

    I try to confirm an account (email) with the API but it doesn't work.
    I try to do a PUT with email:confirmed but doesn't work too.

    Is it possible with write api ?

    Thanks

  • 0 Votes
    2 Posts
    968 Views

    @h7 tried on a different Debian 7 (Wheezy) server, to make sure this is a common issue:

    Node.js v4.2.2 Redis server v=3.2.11 NodeBB v1.0.3

    NodeBB installs again, without errors but the log comes back with the exact same [2458] - error: undefined

    npm rm nodebb-plugin-emoji-one npm install [email protected]

    fixed that error, now:

    info: Time: Sun Oct 08 2017 04:59:32 GMT+0300 (MSK) info: Initializing NodeBB v1.0.3 [outdated] nodebb-plugin-emoji-one installed v1.1.4, package.json requires 1.1.0 warn: One or more of NodeBB's dependent packages are out-of-date. Please run the following command to update them: warn: ./nodebb upgrade [cluster] Child Process (6503) has exited (code: 0, signal: null)

    OK, removing the plugin npm rm nodebb-plugin-emoji-one and ./nodebb start worked, NodeBB v1.0.3 running, still can't log-in:

    warn: [meta/dependencies] Bundled plugin nodebb-plugin-emoji-one not found, skipping dependency check. [minifier] file not found, node_modules/socket.io-client/socket.io.js [minifier] file not found, node_modules/socket.io-client/socket.io.js info: NodeBB Ready info: Enabling 'trust proxy' info: NodeBB is now listening on: 0.0.0.0:4567 error: /login invalid csrf token error: /login invalid csrf token

    using older versions of socket.io:

    npm remove socket.io npm remove socket.io-client npm install [email protected] npm install [email protected]

    did the trick, NodeBB v1.0.3 running and ready for myBB to NodeBB transition

  • 0 Votes
    6 Posts
    2k Views

    I can confirm that npm downgrading to npm@4 solves this issue.
    Had the same one.. Maybe it's worth to mention it at the release page.

    Thank you @PitaJ