Step 1: Install NodeBB, Step 2: Set up reverse proxy?

General Discussion
  • Total newb here. I installed nodeBB on digital ocean using @psychobunny 's excellent guide. Then pointed the DNS appropriately.

    But I can't figure out how to set up the reverse proxy on nginx. I installed the latest nginx and then started reading the wiki. Not having any experience in this, I googled around plus found a couple threads on here about people with specific issues. I have a general issue: don't know where to start!

    There's this part: "NGINX-served sites are contained in a server block. This block of options goes in a specific place based on how nginx was installed and configured:"

    And this part: "Below is the basic nginx configuration for a NodeBB build running on port 4567:"

    I'm guessing I have to edit some text configuration file for the latter (emacs? I don't really know what I'm talking about), and for the latter I'm not sure what to do with "files here must be aliased to" and "filenames must end in .conf".

  • @Kamal-Patel

    Where are you trying to install NodeBB - subdomain or as the main site, that is, nodebb.website.com or website.com?

  • @planner

    Main site. It's up and running at mainsite.com:4567, but my frazzled brain can't figure out the reverse proxy instructions.

  • What files do you have in the conf.d folder?

    On my machine I can find this by using the following commands

    cd /etc/nginx/conf.d
    ls

  • @HolyPhoenix said:

    ls

    There aren't any files listed in that folder. Hmm...

    In the "sites-available" folder, the ls command produced "default".

  • @Kamal-Patel

    hmmm.... If I got to that point I would just add it to the standard nginx.conf at the bottom. The default file may work maybe...? I don't really know what that is for. If I got to that point I would just tack the proxy info to the bottom of the nginx.conf file. For me this is at /etc/nginx/nginx.conf.

    Mine looks like

    server {
          listen   myipaddress:80;
         server_name domain.com www.domain.com;
         error_log path/to/logs error;
    
         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;
    
            # Sockect.IO Support
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    }
    

    Edit: I don't know why it put some of it in a nice box. I don't know markup well enough to know why, but that whole section is there

  • As @HolyPhoenix suggested, you can place it at the bottom of the nginx.conf file. However....

    Purely for organization purposes, I prefer using the sites-available folder. Your nginx.conf file is probably set up to look there already.

    Create a new file called whatever you want:

    • cd /etc/nginx/sites-available
    • touch hotpotato

    Then edit this file:

    • nano hotpotato

    Paste the config in there, altering as necessary, and then activate the file:

    • cd ../sites-enabled
    • ln -s ../sites-available
  • I tried what Julian said and got this message:

    ln: failed to create symbolic link `./sites-available': File exists

    And this error when running nginx -t:

    nginx: [crit] pread() "/etc/nginx/sites-enabled/sites-available" failed (21: Is a directory)
    nginx: configuration file /etc/nginx/nginx.conf test failed

    I tried all three of the methods listed in the documentation, but no dice. Any tips? I just did the regular digital ocean setup for dummies, but I can't get past the reverse proxy step even after reading every single mention of "nginx" on the forum. I feel like a grade-A moron 😞

    By the way, the site is at http://nutritionask.com:4567.

    When I use the nginx.conf file I paste the server block at the end and get this error:

    2014/05/16 15:33:47 [emerg] 30304#0: "server" directive is not allowed here in /etc/nginx/n ginx.conf:97
    nginx: configuration file /etc/nginx/nginx.conf test failed

    Here is what I pasted. How do you make it all cool looking with the black background btw?

    server {
    listen 0.0.0.0:80;

    server_name nutritionask.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;
    
    # Socket.IO Support
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    

    }
    }

  • Seems like you linked the sites-available directory inside sites-enabled. Give this a shot:

    rm -rf /etc/nginx/sites-enabled/sites-available
    
    ln -s /etc/nginx/sites-available/hotpotato /etc/nginx/sites-enabled/hotpotato
    

    and then run nginx -t, if all checks out reboot nginx and hopefully you're good 🙂

  • @psychobunny

    You're a good luck charm! I moved the lines up into the http directive in the nginx.conf file, and it worked. I've been at this for a few days...is there any way that (if I learn a bit more about commands and such), I can help add a few more lines to the reverse proxy documentation page so that dummies like me won't screw up?

    Also, do you know if I have to delete the lines from the other locations I tried (sites-available, default) and remove the link? Just wanna make sure that having the same stuff in three different locations isn't gonna screw something up later.

  • @psychobunny @julian

    Thanks for this thread, and I think this kind of information can be placed in docs or wiki.

    I use nginx now, and the default page of mydomain.net works, and mydomain.net:4567 works for nodeBB.

    Now, I try to implement sub.mydomain.net proxy to 127.0.0.0:4567 (nodeBB), so I tried:

    /etc/nginx/sites-available/subdomain

    server {
          listen   myipaddress:80;
         server_name sub.mydomain.net;
         error_log ./log error;
    
         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;
    
            # Sockect.IO Support
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    }
    
    

    But seems not working.

    I properly set the symbolic link in /etc/nginx/sites-enabled/

    ln -s /etc/nginx/sites-available/subdomain
    

    So here is no problem, I think.

    Please advice ,
    Thanks.

    PS. reading

    I've changed

    server {
          listen   myipaddress:80;
    //........
    

    and
    sudo /etc/init.d/nginx restart

    The result is same...
    sub.mydomain.net does not lead to mydomain.net:4567...

    Ubuntu 14.04
    nginx version: nginx/1.6.0

  • @Ken-OKABE What do you see when you go to sub.mydomain.net? An nginx error?

    Make sure the subdomain is routed properly via your DNS server (so that sub.mydomain.net goes to the same ip as mydomain.net), and make sure that nginx is reading configuration files from sites-enabled/, you can check that by looking near the bottom of nginx.conf.

  • @julian No, the browser says - Oops! Google Chrome could not find sub.mydomain.net

    Currently, I'm trying to figure out how to observe nginex behavior with log.

    So far, simply,
    mydomain.net shows the frontpage of nginex.
    mydomain.net/4567 shows the nodeBB properly.

    Thanks

  • @julian said:

    Make sure the subdomain is routed properly via your DNS server (so that sub.mydomain.net goes to the same ip as mydomain.net),

    Oh my... I totally miss it!

    You have true insights always. Appreciated Julian.

  • @julian Just works as intended.
    The approach here totally works.
    As you kindly suggested, it's my mistake not to have set subdomain by DNS.
    I somehow misunderstood Ngynx takes care of subdomainsDNS IP routing, my bad.
    Thanks a lot.

  • This post is deleted!
  • This post is deleted!


Suggested Topics