Nginx vhost configuration help



  • 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


  • Gamers

    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


  • Gamers

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



  • This post is deleted!

Log in to reply
 


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.