Linode Tutorial Part 1: Setting Up a Domain, Ubuntu, and Nginx Reverse Proxy for Multiple Routes

Habibi Coding | حبيبي كودنق
Geek Culture
Published in
7 min readFeb 21, 2023
tutorial banner

In this comprehensive tutorial, I will guide you through the process of setting up an Ubuntu server on Linode. We will start by adding your domain to Linode and connecting to the Ubuntu server. Next, we will properly configure the server to ensure optimal performance. Finally, we will install Nginx as a web server and reverse proxy, providing step-by-step instructions for a seamless setup process.

Prerequisites

  1. You own a domain
  2. You have an account at https://www.linode.com/

Who should read this tutorial series?

This tutorial series is designed for individuals who have purchased a domain and are looking to host their front-end or back-end applications. If you’re interested in learning how to set up Nginx with separate routes for your Frontend and Backend applications, then this tutorial is for you.

Disclaimer

This tutorial series may not be suitable for individuals who have already set up their domain on another cloud platform and have a thorough understanding of Nginx routing.

Prologue

If you’ve seen my recent video on Habibi Coding YouTube, you might be wondering why I switched from Digital Ocean to Linode as my cloud platform. The reason for this change is that I encountered issues with Digital Ocean’s Teams function, which I used to separate my YouTube account from my private project account. To resolve these problems, I opted to use Linode’s Shared CPU plan, which is priced at $5 per month, for my YouTube and Medium tutorials.

What the end result will look like:

finished server blocks config

Generate an SSH Key Pair on MacOS

If you use Windows or a Linux distro you just need to Google how to create an SSH key on your OS. (If you already have an SSH key then skip these steps)

  1. Either open Terminal or iTerm2
  2. Type ssh-keygen -t rsa
  3. Enter the file in which to save the key: (I would just press Enter)
  4. Enter passphrase (just press ENTER for no passphrase):
  5. You should see something like this:
ssh key creation

6. Type ls -la

7. Check if you see .ssh folder

.ssh folder

8. Type pbcopy < ~/.ssh/id_rsa.pub

iTerm2

9. Open Linode Console (https://cloud.linode.com/) then click on your profile in the top right corner and select SSH Keys

Linode Console

10. Then click on “Add an SSH Key” give it a label that helps you know from which device this key is and make sure you paste the key inside of “SSH Public Key”. It should start with “ssh-rsa” and don’t forget to press “Add Key”.

Add an SSH Key
Add SSH Key window

11 Check if there is a Key.

SSH Keys overview

Spin up a Ubuntu server — Yalla | يلا

Click on Create Linode

Linode Console

Then PLEASE CHOOSE “Ubuntu 22.04 LTS” as distribution.

Then at Region choose from the dropdown your region (select what is closest to you).

At Linode Plan click on the “Shared CPU” tab and choose the cheapest for Nanode 1 GB or higher if you want. But the cheapest is more than enough for this tutorial.

Lindodes/Create

I gave my Linode a label: “habibicoding-ubuntu

Linode Lable

At Root Password choose a good password you can remember, or write it down somewhere please, you are going to need it later.

set up Root Password

At “SSH Keys” you should see the one we created before and select it, please.

SSH Keys

Make sure you have the same summary as I have, except for the region. Lastly, press “Create Linode” and wait for a few seconds.

Linode summary

The creation of your Linode instance can take a few minutes, when the server is up, click on your Ubuntu instance.

Ubuntu instance

12. Press the copy button at the field SSH Access

SSH Access

13. Paste it into your terminal (If you are using Windows or Linux check out this video)

ssh command in iTerm2

14. Then enter ls -la to see if everything works

ls -la

Set the name servers of your domain to Linode’s servers, follow these steps:

  1. Go to your Linode console
  2. Click on the “Domains” icon on the left side
  3. Click on the “Create Domain” button.”
Domains

Next, enter your domain name, and your preferred email address, and select “Do not insert default records for me” under the “Insert Default Records” option.

Create Domain

You should see now below your SOA Record the NS Record. Copy those and replace them with your domain provider ones.

NS Record

I am using https://my.world4you.com/ and I can only set four name servers for my domain. This might be different for your domain provider. Note that DNS propagation can take a few days until it is done.

Linode name servers

Go back to your Linodes console and copy your IP-Address

Linodes console

Then click again on the “Domains” menu on the left and click on your domain then scroll down until you see “A/AAAA Record” and click on “Add an A/AAAA Record

Add an A/AAAA Record

Next, create a Hostname record by entering @ and pasting your IP address in the corresponding field, then click on 'Save'.

Create A/AAAA Record

To add subdomains or a wildcard domain, go back to the Linode Console under the “Domains” section. To add a subdomain, simply enter the desired subdomain as the Hostname, and enter its corresponding IP address. To add a wildcard domain, enter: * as the Hostname and your Linode’s IP Address. This wildcard domain will serve as a match for all subdomains that do not exist.

wildcard

Don’t forget also set the DNS records on your domain provider’s side.

DNS record
A & CNAME

For best results, it is recommended to enable editing of the Reverse DNS. To do this, follow these steps:

1. Go to the Linode Console and click on “Linodes” in the left-side menu.
2. Click on your Linode instance and select the “Network” tab.
3. Scroll down to the “IP Addresses.” section.
4. Click on “Edit RDNS” and remove the input with your domain name.

Edit Reverse DNS

In case you get the error message: “We were unable to perform a lookup for ‘{your Domain}’ at this time.” just skip these steps.

Then you should see in the IP Addresses overview your domain name as Reverse DNS.

RDNS

After that open a new local Terminal on your local machine and type:

dig @ns1.linode.com {your-domain}
dig command

At the “ANSWER SECTION” the IP-Address must match that of your Linode instance which you see at https://cloud.linode.com/linodes. If not then DNS propagation still needs time.

You can also test if you see entries with another DNS like the one from Google: 8.8.8.8.

dig command with Google DNS

With that, we conclude the first part of this tutorial series. If you found it useful and informative, give it a clap. Here is Part 2:

Don’t forget to check out the video version of this article on our YouTube channel at https://www.youtube.com/@habibicoding.

I would also like to extend my gratitude to the Linode team for their comprehensive documentation, check also check out their video. I highly recommend taking a look at their resources as well.

--

--