Assistance Configuring Nginx on Ubuntu 14.04 with NodeBB

Technical Support
  • Hey guys! I'm having a couple issues and I'm sure it's something rather simple. I'm not usually one to ask for help unless I'm just completely lost, so here I am!

    I'm having an issue setting up a proxy on my nginx server. All I'm looking to do is load NodeBB from 127.0.0.1:4567 for my domain. It's working fine with the trailing port (forgeunity.com:4567), but obviously I want it to load on port 80.

    Forgeunity.com will load the default nginx page (until I deleted the default configuration, oops!), but I can't seem to get it to load my NodeBB installation. My current attempt is pretty much just from the NodeBB nginx guide, but here's everything I have:

    Here's my nginx configuration, forgeunity:

    server {
        listen 80;
    
        server_name forgeunity.com;
    
        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;
    
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    }
    

    My NodeBB config.json

    {
        "url": "http://forgeunity.com",
        "secret": "SECRET",
        "database": "redis",
        "redis": {
            "host": "127.0.0.1",
            "port": "6379",
            "password": "",
            "database": "0"
    }
    

    }

    For further information about my server, here's what I did:

    1. Spun up a Ubuntu 14.04 Node image (which is just preinstalled Node v4.2.1)
    2. Used NVM to install Node v0.10.40
    3. Installed and configured NodeBB to work directly on my server via its port
    4. Setup my domain name on my domain registrar side as well as DigitalOcean's side
    5. Installed nginx and "configured" it to not work properly, obviously
    6. Came here for assistance after hours of failure 😣

    Thanks in advance, everyone!

  • I have a very similar setup, except that I am using numerous instances of nodebb within an upstream block, which I would suggest on your droplet depending on it's size:

    upstream forum_nodes {
        ip_hash;
        server 127.0.0.1:4567;
        server 127.0.0.1:4568;
        server 127.0.0.1:4569;
        server 127.0.0.1:4570;
    }
    
    server {
        listen 80;
    
        server_name forum.somedomain.tld;
    
        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_redirect off;
    
        # Socket.IO Support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    
        gzip	on;
        gzip_min_length	1000;
        gzip_proxied	off;
        gzip_types      text/plain application/xml application/x-javascript text/css application/json;
    
        location @nodebb {
            proxy_pass http://forum_nodes;
        }
    
        location ~ ^/(images|language|sounds|templates|uploads|vendor|src\/modules|nodebb\.min\.js|stylesheet\.css|admin\.css) {
            root /home/nodebb/nodebb/public/;
            try_files $uri $uri/ @nodebb;
        }
    
        location / {
            proxy_pass http://forum_nodes;
        }
    }
    
  • Check the docs for a list of steps:
    https://docs.nodebb.org/en/latest/configuring/proxies/nginx.html

    Also change location / to location ~^/


Suggested Topics


  • 0 Votes
    4 Posts
    3k Views

    The common causes for a session mismatch error are usually one of the following:

    1. Mis-configured URL parameter in your config.json file

    If you have a misconfigured url value in your config.json file, the cookie may be saved incorrectly (or not at all), causing a session mismatch error. Please ensure that the link you are accessing your site with and the url defined match.

    2. Improper/malformed cookieDomain set in ACP

    Sometimes admins set this value without realising that they probably don't need to set it at all. The default is perfectly fine. This is what the config looks like:

    Cookie Domain setting

    If this is set, you'll want to revert the setting by editing your database directly:

    Redis: hdel config cookieDomain
    MongoDB: db.objects.update({ _key: "config" }, { $set: "cookieDomain": "" });

    3. Missing X-Forwarded-Proto header from nginx/apache

    If you are using a reverse proxy, you will need to have nginx pass a header through to NodeBB so it correctly determines the correct cookie secure property.

    In nginx, you will need to add the directive like so:

    location / { ... proxy_set_header X-Forwarded-Proto $scheme; ... }
  • 0 Votes
    4 Posts
    1k Views

    That is a warning. That should not be causing issues for when you visit your site. Check for other errors in the nodebb log and in your browser console.

  • 0 Votes
    6 Posts
    2k Views

    @louisemcmahon something like this can work okay:

    Have two git remotes: origin and fork

    git remote rm origin git remote add origin https://github.com/nodebb/nodebb.git git remote add fork https://example.com/your/repo.git

    Then you can used these named remotes for updating / pushing like so:

    # pull and merge latest changes from NodeBB git pull origin # push latest changes to your repo git push fork

    That will make updating things easier.

  • 0 Votes
    2 Posts
    723 Views

    I'm having the same issue!

    If anyone has any experience with this, it would be really helpful.

  • 0 Votes
    11 Posts
    4k Views

    @flex it works, thanks