Install Discourse on Oracle Cloud Free Tier

--- Oracle offers a free plan including two low-spec virtual machines able to run Discourse. This trial has no time limit.

:warning: These virtual machines are very slow and I advise you not to use them for hosting a community.
That said, it can be enough to host a very small community that doesn’t care about the slowness, or for personal projects/tests.


Requirements

  • A credit card number - you won’t be charged anything, but it’s needed to register the free account
  • A domain name
  • An email provider
  • Discourse installation will be identical to the official guide, but this tutorial will guide you through Oracle’s Interface and configuration.

For this tutorial, we’ll consider that you’re using Windows 10, and we’ll use PuTTY to connect to your server via SSH.

Create your free trial

First, create a trial account on Cloud Free Tier | Oracle
Your account creation is not instant and you may have to wait for a few minutes or hours (or days, in some cases) for your account to be validated.

When your account is created, go to https://cloud.oracle.com and log in.

Create your server

Click “Create a VM Instance” (VM meaning “Virtual Machine”):

Configure your server

(Optional) rename your instance to something meaningful, so you’ll know what it refers to in your virtual machine list:

I’ll name mine the same as the domain name I’ll use: “Canapin.win”:
image

In Image and shape, change the default operating system to Ubuntu by clicking edit:

Choose Canonical Ubuntu, then click Select Image at the bottom of the page:

On the Add SSH keys, multiple options are available:

Click Save Private Key and Save Public Key.
It will download a .pub public key, and a .key private key. Store them in some folder.

Convert the private key for PuTTY

:raised_hand: We’ll stop browsing Oracle’s interface for a while, and we’ll go back to it later.

In this tutorial, we’ll connect to our server with PuTTY. Since the generated private key is incompatible with PuTTY, we’ll use a tool named PuttYgen to convert the key so it’s compatible with PuTTY.

Install PuTTY from the official site: Download PuTTY: latest release (0.77)

After installing PuTTY, you should be able to look up PuTTYgen with the Windows search:


If it doesn’t appear here, you can locate it here: C:\Program Files\PuTTY\puttygen.exe

Start PuTTYgen.
Select Conversions → Import key:
Locate your .key file downloaded from Oracle’s interface and click Open to validate the file selection.
image

Some fields will appear and will be automatically filled. Don’t modify them unless you know what you’re doing.

(Optional) add a passphrase to your key. Think of it as a password to enhance security that will be asked each time you log in to your server.
Then, click Save private Key and store it in a folder:
image

Finalize the server’s creation

:point_right: Time to go back to Oracle’s interface.

Scroll down to the end of the page, and click the Create button:

image

Wait for a about a minute for the server to be created. The page and its information will be updated in real-time. No need to refresh:

Make sure your domain point to your newly created server’s IP

Make your domain point to the server’s IP address and wait for the DNS propagation.
:information_source: This won’t be explained in this tutorial and must be done in the DNS configuration of your domain name’s provider.

Note the server’s created username

Note the username the server automatically created. Here, the username is ubuntu.
image

Configure Oracle’s firewall

Now, here goes a very specific Oracle’s configuration section to make Discourse work. We will open some ports on a firewall.
Click Public Subnet in the *Primary VNIC section:
image

Click the Security list link in the Security Lists section:
image

Click Add Ingress Rules in the Ingress Rules section:

Fill in the rules as such:

  • Set SOURCE CIDR to 0.0.0.0/0
  • Set DESTINATION PORT RANGE to 80, 443
    Click “Add Ingress Rules”:

Check that your rules were properly added:

Connect to your server via SSH with PuTTY

Start PuTTY and fill the Host Name (or IP address) with the IP address of your newly created server:
image

On the left tree menu, go to ConnectionSSHAuth.
In the “Authentification parameters”, locate your private key (the file with the .ppk extension you generated with PuTTYgen) by clicking Browse…:
image

Click Open:
image

Click Accept:
image

Log in by writing your username (ubuntu) and press enter:
image
Enter the passphrase if you chose one in PuTTYgen.

PuTTY will verify your private key, and you should be logged in:
image

Configure Ubuntu’s firewall (iptables)

At this stage, we still can’t install Discourse. We must open some ports directly in Ubuntu.

Log as root by writing sudo su and press Enter.

Add these rules to iptables by writing:

iptables -I INPUT 5 -i ens3 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 5 -i ens3 -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT

Note: the “5” means that both rules will be added starting from line 5, just before the DENY ALL input firewall rule. The line number could have to be changed in the future if Oracle changes the default iptables configuration on their Ubuntu image in the future

image

Save the updated rules with:

netfilter-persistent save

image

Install Discourse

Now, your server should be ready to install Discourse.
Just follow the official steps: discourse/INSTALL-cloud.md at main · discourse/discourse · GitHub

(40 minutes of building time later… :snail:)


:warning: Again, Oracle free servers are slow. Installing and rebuilding take ages.
Even installing themes or components from the interface can sometimes time out.
Be warned… And patient. :person_in_lotus_position:


Related discussion with various information and resources: Self hosting for free with Oracle Cloud

7 Likes