Forum on a Sub-domain



  • Hey Guys, this forum is amazing the community as well.

    I have a website hosted with Godaddy let call it mywebsite.com and I have Nodebb forum application installed on a Digitalocean cloud server.

    Now i want to make the forum in a sub-domain of my website like "forum.mywebsite.com" and when people search for a topic of mine in my forum on Google, I want Google to display the link of my sub-domain not the Digitalocean IP server where the forum is installed and all the traffic that comes from the forum to be calculated for my main domain. How do i do that?

    I hope my point is clear.

    Thanks


  • GNU/Linux

    First of all, let's use example.com as everybody does (this has some legal reasons behind) ;)

    If you're using nginx it's fairly simple: change the server_name within the nginx config (see the examples within the docs) and the config.json (url property) within NodeBB-root as well.

    If you're not using nginx, please state how you bind NodeBB to port 80/443 currently. And consider moving towards nginx.

    You also need to have set-up a CNAME DNS record for the sub-domain so your server gets the traffic.
    For example.com it would look like
    0_1461066981282_2016-04-19-135450_1920x1080_scrot.png
    on this configuration page. Changing this will normally take a period of 4 to 24 hours.
    There are other entry types, like wildcards, but I prefer the one above.

    If everything is set-up correctly, no search engine should prefer the IP over the hostname.



  • @frissdiegurke said in Forum on a Sub-domain:

    If you're using nginx it's fairly simple: change the server_name within the nginx config (see the examples within the docs) and the config.json (url property) within NodeBB-root as well.

    Should I change the server_name on the nginx config file to the sub-domain name where i want to locate the forum? also I forgot to mention that my website running under SSL is that going to change any of the steps you mentioned?


  • GNU/Linux

    @hnahli said in Forum on a Sub-domain:

    Should I change the server_name on the nginx config file to the sub-domain name where i want to locate the forum?

    Yes.

    also I forgot to mention that my website running under SSL is that going to change any of the steps you mentioned?

    No.



  • @frissdiegurke said in Forum on a Sub-domain:

    on this configuration page. Changing this will normally take a period of 4 to 24 hours.

    The link in here doesnt work it is displaying a blank page.

    The CNAME configuration has to be done in the example.com hosting company isnt it?


  • GNU/Linux

    If you've registered the digitalocean nameservers to your domain, the CNAME configuration has to be done on digitalocean side (replace the prefix "example.com" with your domain within the link and it should work when you're logged in digitalocean.



  • @frissdiegurke My domain registered with Godaddy and digitalocean i have only hired a cloud server and installed Nodebb on it. I did replace the example.com with my domain and it didnt work


  • GNU/Linux

    The link step by step:
    log into digitalocean; go to networking -> domains -> magnifier button ("view") of your domain

    If you don't have any listing of your domain there yet, you probably have set-up the DNS record at godaddy directly. In that case you need to add an entry like

    forum.example.com. 1800 IN CNAME example.com.
    

    over there.



  • @hnahli said in Forum on a Sub-domain:

    My domain registered with Godaddy and digitalocean

    Explain a bit more. Godaddy is your registration provider. Are they also your DNS provider? Ie., are they doing the DNS resolution or do you have Godaddy pointed to Digital Ocean's nameservers and Digital Ocean is doing the DNS resolution?



  • @rod Godaddy are handling everything registration and DNS records



  • @hnahli Ok. So now as frissdiegurke mentioned you need to tell Godaddy's DNS system that you want to add a CNAME record entry pointing your forum.example.com to your example.com. Don't miss the tailing period as frissdiegurke displayed.

    In your Nodebb config.json you need to change your URL to be forum.example.com

    Also be sure your webserver configuration has a reverse proxy entry for forum.example.com to get to your NodeBB/Node.js instance. Possibly 127.0.0.1:4567



  • @rod said in Forum on a Sub-domain:

    Also be sure your webserver configuration has a reverse proxy entry for forum.example.com to get to your NodeBB/Node.js instance. Possibly 127.0.0.1:4567

    in Digitalocean or Godaddy? I am kind of lost :(



  • @hnahli The webserver configuration will be on your Digital Ocean server. Are you using Nginx as the webserver or Apache or some other?



  • @rod I am using Nginx



  • @hnahli

    Adding a server block similar to this should work:

    server {
        listen       80;
        server_name  forum.example.com;
    
        root   /var/www/forum.example.com/html;
        index  index.html index.htm;
    
        access_log  /var/log/nginx/access.forum.example.com.log;
        error_log /var/log/nginx/error.forum.example.com.log;
    
        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";
        }
    }
    


  • @rod I have done all the steps and attempting to start Nodebb I got this error:

    19/4 12:46 [21016] - error: Error: listen EADDRINUSE :::4567
    at Object.exports._errnoException (util.js:870:11)
    at exports._exceptionWithHostPort (util.js:893:20)
    at Server._listen2 (net.js🔢14)
    at listen (net.js:1270:10)
    at Server.listen (net.js:1366:5)
    at listen (/var/www/nodebb/forums/src/webserver.js:179:17)
    at /var/www/nodebb/forums/src/webserver.js:57:3
    at EventEmitter.<anonymous> (/var/www/nodebb/forums/src/emitter.js:17:5)
    at emitNone (events.js:67:13)
    at EventEmitter.emit (events.js:166:7)
    19/4 12:46 [21016] - error: NodeBB address in use, exiting...



  • @hnahli Maybe you still have NodeBB running. What is the output of this from your command line:

    ps fax | grep node



  • @rod @frissdiegurke this guide worked like a charm and it didnt fail from first command line.

    My problem now is that the main domain is on SSL and sub-domain where the nodebb is not and after mailjet integration it is sending confirmation using https

    Please advise


Log in to reply
 


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