Nginx vhost configuration help

Technical Support
  • Greetings!

    I have decided to jump back into setting up a NodeBB forum after setting up my server via command line (no gui, no management front end) and it's been a fun/challenging ride 😉

    I have managed to get very close on a dedicated server using Nginx with a dev vhost ...

    I can get NodeBB to run using 100foldpro.com:4567 but when trying to use the actual URL where NodeBB is installed ( 100foldpro.com/bbs ) I get NodeBB showing up without any styling as the styles and .js files are trying to reference the root URL and not the directory.

    Here are my configs ...

    added to my vhost config file

        listen          80;
        server_name 100foldpro.com;
        index           index.html;
        root /pathToMyVhost/100foldpro;
    
        <....snip other parameters for a Drupal install .... >
    
    
        location /bbs {
            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://100foldpro.com:4567/;
            proxy_redirect off;
    
            # Socket.IO Support
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    

    Here's the config.json

    {
    "url": "http://100foldpro.com:4567",
    "secret": "bunch o numbers",
    "database": "redis",
    "redis": {
        "host": "127.0.0.1",
        "port": "6379",
        "password": "NOPE",
        "database": "0"
      }
    } 
    

    I tried setting the URL of the subdirectory in the conf.json file to http://100foldpro.com:4567/bbs but I get the same output but with errors on the page that "/ doesn't exist"

    I'm currently waiting for a CNAME dns change to see if I can just use the subdomain with a vhost conf for Nginx to run the subdomain from, but I would have thought setting up the subdirectory would have worked. I'm sure there's something in the Nginx host conf not right.

    Thanks ... Pops

  • @PopsRocker said:

      proxy_pass http://100foldpro.com:4567/;
    

    Change it to:

    proxy_pass http://0.0.0.0:4567/;
    

    And in the Config,json you have to change it to your default Domain.
    So if you use nginx and pass it to 4567. Your Standard port is 80 so remove 4567

    "url": "http://100foldpro.com:4567",
    

    into

    "url": "http://100foldpro.com/bbs",
    

    and remove the root location at the nginx conf file at the beginning. reload nginx and try it again 🙂

  • Thanks Andi,

    I made the changes you suggested and still have the same results. After making the edits I relaunched both Nginx and NodeBB.

    The reason I have the root path is to direct the vhost to the Drupal installation.

    It's looking like the easier way to accomplish the install is with the sub-domain. One the dns propagated the forum is working perfectly. I was trying to understand the Nginx conf as I am learning a lot, and the more I do this the easier it is getting to troubleshoot on my own without having to rely on tutorials.

    Anyway, I've spent all day trying to make the sub directory work, so I'll go with what works 😉

    I'll submit a detailed post on how I have it all configured once I get further along in my understanding.

    Thanks again ... Pops

  • config.json

    "url": "http://100foldpro.com/bbs",
    

    Nginx config

    # NodeBB
    location /bbs {
    
    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/bbs; 
    proxy_redirect off; 
    
    proxy_http_version 1.1; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
    }
    
  • This post is deleted!
  • @Ali using the config changes you suggested has stopped errors from showing up in the DOM but the styles are still not showing up on the page. I thought it may be a cache but even checking on a different browser shows the forum stripped of styling.

    Here's the html in between the head tags.

    <head>
    <title>Home | NodeBB</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="content-type" content="text/html; charset=UTF-8">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta property="og:site_name" content="NodeBB">
    <meta name="keywords">
    <meta name="msapplication-badge" content="frequency=30; polling-uri=http://100foldpro.com/bbs/sitemap.xml">
    <meta name="msapplication-square150x150logo">
    <meta name="title" content="NodeBB">
    <meta name="description">
    <meta property="og:title" content="Home | NodeBB">
    <meta property="og:type" content="website">
    <link rel="stylesheet" type="text/css" href="/bbs/stylesheet.css?8ec00012-b924-4f74-8476-8a8883b57566">
    
    <link rel="icon" type="image/x-icon" href="/bbs/favicon.ico">
    <link rel="apple-touch-icon" href="/bbs/apple-touch-icon">
    
    <!--[if lt IE 9]>
    	<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/2.3.0/es5-shim.min.js"></script>
    	<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7/html5shiv.min.js"></script>
    	<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
    	<script>__lt_ie_9__ = 1;</script>
    <![endif]-->
    
    <script>
    	var RELATIVE_PATH = "/bbs";
    	var config = JSON.parse('{"relative_path":"/bbs","socketioTransports":["polling","websocket"],"websocketAddress":"","version":"0.8.2","siteTitle":"NodeBB","browserTitle":"NodeBB","showSiteTitle":true,"postDelay":"10","minimumTitleLength":"3","maximumTitleLength":"255","minimumPostLength":"8","maximumPostLength":"32767","hasImageUploadPlugin":false,"maximumProfileImageSize":"256","minimumUsernameLength":"2","maximumUsernameLength":"16","minimumPasswordLength":"6","maximumSignatureLength":"255","maximumAboutMeLength":"1000","useOutgoingLinksPage":false,"allowGuestSearching":false,"allowGuestUserSearching":false,"allowGuestHandles":false,"allowFileUploads":false,"allowProfileImageUploads":false,"allowTopicsThumbnail":false,"allowAccountDelete":true,"privateUserInfo":false,"privateTagListing":false,"usePagination":false,"disableSocialButtons":false,"disableChat":false,"maximumChatMessageLength":1000,"maxReconnectionAttempts":5,"reconnectionDelay":1500,"minimumTagsPerTopic":"0","maximumTagsPerTopic":"5","minimumTagLength":3,"maximumTagLength":15,"topicsPerPage":20,"postsPerPage":20,"maximumFileSize":"2048","theme:id":"nodebb-theme-persona","theme:src":"","defaultLang":"en_GB","userLang":"en_GB","loggedIn":false,"cache-buster":"8ec00012-b924-4f74-8476-8a8883b57566","requireEmailConfirmation":false,"topicPostSort":"oldest_to_newest","categoryTopicSort":"newest_to_oldest","csrf_token":"wduJjZD0-w9dSRNThD4C98jw5VZ8_47bOAPY","searchEnabled":false}');
    	var app = {
    		template: "categories",
    		user: JSON.parse('{"username":"Guest","userslug":"","picture":"https://s.gravatar.com/avatar/d415f0e30c471dfdd9bc4f827329ef48?size=128&default=identicon&rating=pg","status":"offline","banned":false,"uid":0,"isAdmin":false,"email:confirmed":false}')
    	};
    </script>
    <script src="/bbs/nodebb.min.js?8ec00012-b924-4f74-8476-8a8883b57566"></script>
    <script>
    require.config({
    	baseUrl: "/bbs/src/modules",
    	waitSeconds: 3,
    	urlArgs: "8ec00012-b924-4f74-8476-8a8883b57566",
    	paths: {
    		'forum': '../client',
    		'vendor': '../../vendor',
    		'mousetrap': '../../bower/mousetrap/mousetrap'
    	}
    });
    </script>
    
    
    
    </head>
    

    Very puzzled by this ... Pops

  • @PopsRocker can you paste both nodebb & nginx config here? I think you're missing something.

  • This post is deleted!

Suggested Topics


  • 0 Votes
    3 Posts
    84 Views

    As always, @pitaj's readme is pretty thorough, if you haven't discovered it 😄

    https://github.com/benchpressjs/benchpressjs/blob/master/docs/operators.md

  • NodeBB on Oracle VPS [I need help!]

    Unsolved Technical Support
    0 Votes
    4 Posts
    283 Views

    Your issues with firewall are likely because Oracle is, essentially, using firewalld rules for all their images, even ones that don't have it included. So if you are running on Ubuntu, and trying to use ufw like most tutorials will recommend you do, it will do nothing with the default iptables entires and be essentially useless. And the bigger problem is that some of their rules are required to start to VMs (they need iSCSI access rules on boot)

    The easy solution is to just give in to Oracle's config and install firewalld:

    sudo apt install firewalld sudo systmctl enable --now firewalld

    (And ensure ufw is disabled)

    You can then manage rules using firewall-cmd. For example:

    sudo firewall-cmd --permanent --add-service={http,https} sudo firewall-cmd --reload

    Will allow http/https traffic.

    The second option is the one I assume you tried: fix iptables and use ufw. But this is a bit more complex than it seems.
    First issue is that IIRC the iptables rules will be applied again on reboot. Now, cloud init can be disabled, but there is another issue - the iSCSI rules.
    The official Oracle workaround for ufw potentially making the VMs unbootable is "don't use ufw" (https://docs.oracle.com/en-us/iaas/Content/knownissues.htm#ufw), and while you should be able to just ensure everything is correctly configured with ufw, I honestly stopped bothering. firewalld works fine for me, so, like Oracle, I would recommend that route instead.

    Additionally there is separate OCI networking and their firewall. You have to remember that Network Security Groups override Security Lists, so if you have one assigned to your VNIC, you need to edit it instead of the subnet-wide SL.

    If there is something else specifically you need help with you'll need to give more details - this post is just based on a guess you have the common issues.

  • 0 Votes
    6 Posts
    618 Views

    @pitaj try npm install --production

  • 0 Votes
    2 Posts
    165 Views

    Nevermind, figured it out.
    Inside of config.json there is the url field and a port field... I had a port inside of the URL field, and I removed the port from the url and restarted nodebb, and it's working now!

  • 0 Votes
    9 Posts
    2k Views

    @julian said in Anyone here able to help with an NGINX config issue?:

    @Joykiller We're on a pretty old version of Ghost actually 😞

    0.7.1 😬

    Yeah thats what I thought.