Redirect subdomain to NodeBB IP with nginx



  • I am in the process of redirecting a subdomain to my nodebb hosted on DigitalOcean.

    I have added an A Record on my current hosting (where my subdomain is found to point to the IP of my nodebb on DigitalOcean)

    Now, I am confused with how to configure nginx proxies

    I have tried following the docs but, I am not very skilled in backend.

    Sorry for the newbie questions but,

    1. How would I install nginx the proper way? (sudo apt-get install nginx)?
    2. After installing, where do I go to change the proxies so that I can change the IP to direct to my subdomain?

    Thank you!

    Edit: Solved, posting this here now for convenience.

    I managed to solve this. For brand new users who aren't too familiar with web servers and backend (like me) it was fairly easy after some research. Hopefully this will save time for anyone in the future looking to do the same thing.

    How to redirect subdomain to NodeBB IP w/ Nginx

    This assumes that you have already added an A Record that points your subdomain to the NodeBB IP. This is fairly easy to use from your hosting provider.

    There are many tutorials out there and they were helpful but, to me it felt there was plenty of information scattered all over.

    This is what I did to get my subdomain to redirect to my NodeBB installation on DigitalOcean.

    /* Update your package list to get the latest versions and Install Nginx*/
    sudo apt-get update
    sudo apt-get install nginx
    
    /* Nginx is located in /etc/nginx by default */
    
    cd /etc/nginx
    
    /* You want to go to your list of available sites here */
    cd sites-available 
    
    /* Create a copy of the default config and name it to your sites name */
    cp default <your website name>
    
    /* Add configuration files for your website  */
    nano <your website name>
    
    /* Copy and paste config found here: https://docs.nodebb.org/en/latest/configuring/proxies/nginx.html 
     into the server section of the code. 
     NodeBB runs on port <your IP here>:4567 by default  */
    
    /* Enable it */
    cd sites-enabled
    ln -s ../sites-available/<your website name>
    
    /* Restart nginx */
    sudo service nginx restart
    

    Go to your subdomain and make sure it works. Also be sure to change your config.json to your new url.

    Hopefully this helps some beginners out there!


  • GNU/Linux Admin

    1. Yes, should be fine.

    2. /etc/nginx/sites available/nodebb (you create this file)

    Then symlink it to the sites-enabled folder (look up how to use the link command to achieve this.)



  • Thanks @julian

    I managed to solve this. For brand new users who aren't too familiar with web servers and backend (like me) it was fairly easy after some research. Hopefully this will save time for anyone in the future looking to do the same thing.

    How to redirect subdomain to NodeBB IP w/ Nginx

    This assumes that you have already added an A Record that points your subdomain to the NodeBB IP. This is fairly easy to use from your hosting provider.

    There are many tutorials out there and they were helpful but, to me it felt there was plenty of information scattered all over.

    This is what I did to get my subdomain to redirect to my NodeBB installation on DigitalOcean.

    /* Update your package list to get the latest versions and Install Nginx*/
    sudo apt-get update
    sudo apt-get install nginx
    
    /* Nginx is located in /etc/nginx by default */
    
    cd /etc/nginx
    
    /* You want to go to your list of available sites here */
    cd sites-available 
    
    /* Create a copy of the default config and name it to your sites name */
    cp default <your website name>
    
    /* Add configuration files for your website  */
    nano <your website name>
    
    /* Copy and paste config found here: https://docs.nodebb.org/en/latest/configuring/proxies/nginx.html 
     into the server section of the code. 
     NodeBB runs on port <your IP here>:4567 by default  */
    
    /* Enable it */
    cd sites-enabled
    ln -s ../sites-available/<your website name>
    
    /* Restart nginx */
    sudo service nginx restart
    

    Go to your subdomain and make sure it works. Also be sure to change your config.json to your new url.

    Hopefully this helps some beginners out there!


  • GNU/Linux Admin

    Thanks @SimonQ! I'm sure that will be very helpful 🙂


Log in to reply
 

Suggested Topics

| |