How to implement a reverse proxy in Oracle Cloud Always Free Tiers? (1/2)

stephane.delrez
7 min readJun 29, 2020

--

Oracle released a few months ago an Always Free service… When a corporation like Oracle releases free resources, a lot of questions can come to mind: What can I do with those services? Is it really possible to do prototyping on those services or are there too many limitations to do something useful?

In this article we will see how to create a reverse proxy with Oracle Always Free resources. This article will be split in two parts, in the first part we will create and configure the resources that we will use with the reverse proxy. In the second part we will create a load balancer and configure it to become a reverse proxy.

Which resources will we create before setting up our reverse proxy?

  • A VCN, Virtual Cloud Network, this is the equivalent of a local network in Oracle Cloud.
  • We will create a VM with Oracle Linux and install NGINX.
  1. Create the VCN and configure it:

Let’s start creating our network resources, the easiest way is to use the wizard accessible from the home page:

Then we choose VCN with internet connectivity:

We give a name to the VCN and choose the address range for the Virtual Cloud Network, but also for the subnets. In this case, one private and one public. Our VM will be setup in the public network.

The wizard will create all the network component we need, VCN with those characteristics:

Two Subnet’s one public and one private, with those characteristics:

The wizard will also create all the components needed to be able to connect to and from our network:

  • A NAT Gateway that allow to instance in a private subnet to access the internet.
  • A Service Gateway allow instances without public IP to access other services in Oracle Cloud.
  • An Internet Gateway that allow the instance with public IP to connect to the internet and to receive connection from the internet.

Ingress and Egress rules to allow connection SSH as example :

And finally basic routing tables for public and private network :

The creation takes less than 15 seconds, and you will arrive on a confirmation screen that will show you everything that has been created.

We will add rules to the public subnet to allow the http and the https connection, so we go to the VCN page:

We select the public VPN:

We select the security list :

Then we add the ingress rules to allow HTTPS(port:443) and HTTP(port:80) :

2. Creating the VM and configure the NGINX webserver :

Now that the VCN is created we will create the first instance, we go back to home page and click on the Create VM instance button

We give a name to our instance, select the operating system, the availability domain where we want to run our instance, and the shape available. We take the always free eligible solution.

We will also choose the network and the public subnet we just created:

Now we need to add our SSH public key, to encrypt connection to the VM, if you don’t have a couple public key, private key here is the “How to create key for the Oracle Cloud?

We click on create and after a few seconds, our VM is up and running:

Now we have our first instance running on Oracle Cloud, we will connect trough SSH to our instance, this is how to do it : “How to connect to Oracle Cloud Instance using SSH?”. If you succeed in login in your instance, you will see this screen:

When connected to the console, we will run a few command to set up our web-server, first we will update our distribution:

sudo yum update

then we will install NGINX

sudo yum install nginx

Once NGINC is installed , we need to start the server :

sudo systemctl start nginx

The next thing we have to do is open the firewall on the Linux box, so incoming connections are allowed. The first line will open HTTP, the second HTTPS and then we reload the firewall:

sudo firewall-cmd — permanent — zone=public — add-service=http
sudo firewall-cmd — permanent — zone=public — add-service=https
sudo firewall-cmd –reload

Finally, we configure NGINX to start on reboot:

sudo systemctl enable nginx

To test if everything is running, just go to the public IP of your instance, in this example:

If it worked you will see the NGINX welcome page:

We have a web server up and running in Oracle Cloud Infrastructure.

3. Create a custom image from the VM we just created :

We just created a VM, and configure the web server on it, we will use that VM as an image to create a new VM with the webserver already configured. We will start by creating the custom image.

We will go to our instance page, by going to compute->Instance

Then we select the ngnix_webserver instance and in the more action menu, chose the “create custom Image” option:

We give a name to the custom image:

The instance will stop and pass in create images states:

when the instance will be online again, we will create a new instance, and select as OS the custom image we just created:

And then we will create a Compute instance directly from our custom image:

We just have to give a name to the instance and add our SSH public key to the instance, and click on create, there’s nothing else to configure:

When your vm is created, and running just go to the ip address:

If you type the public IP in your web-browser you will see that page:

We can connect and change a little the HTML of the index page to get a different page on the second page:

With this done, we have created all the resources we will needed before starting the implementation of our reverse proxy.

Let’s go to the second part !

--

--