How to run an internet webserver in 20 minutes with zero investments

There are many possibilities of server run using the cloud services from a bunch of companies, but the clearest and truly free option exists due to the “Always Free Resources” conception by Oracle Cloud service. The company provides an amount of cloud stuff per account (named “tenancy” in OCI terminology).

All the conditions are valid on the period of the present post composing. The scope of free services provided by Oracle can be modified at any moment.

So, today there are two virtual server shapes available (don’t you think the bare metal servers are available for free?):

  • VM.Standard.E2.1.Micro (1 x AMD 2-2.25 GHz/1 GB RAM/0.48 GB bandwidth) – two instances per tenancy are provided for free;
  • VM.Standard.A1.Flex – the flexible configuration based on ARM A1 Ampere CPU with adjustable performance. The monthly limits of free service are up to 3000 core-hours and 18 000 GB-hours, which are the equivalent of 4 OCPU with 24 GB of memory installed.

What’s really tempting regarding the purpose of accessibility of the resource from the internet – SIX free public IP addresses per tenancy.

Additionally, under Always Free conditions there is a storage capacity of 200 GB in total for boot (OS), block (partition), and file (folders structured) storage is offered. Each compute instance uses 50 GB storage of this quota automatically as the boot volume and additional space may be attached to any virtual machine or a bunch of.

Most of the time seems to be spent registering an account with the creation of a tenancy record. Despite the resources, which we are going to use, are costless, the valid bank card is needed to be proved. A tiny amount of $1 is charged and returned to the bank account during the validation procedure. Some tell the bank card may be removed from the account after, the others try to go in with virtual cards, but report of fail. I’ve never done either first or second because the reviews and feedbacks of OCI paid service providing politics say, that before the tenancy stops to be free, the warning will be delivered first and the over-free resources deployed during the trial period will be reduced down to Always-Free level. Let’s see what will happen in a little less than a month with my tenancy, hope it will not ruin me completely.

The very important is to check if the Always Free services are provided on the domain in the region which is selected as home. The country/land at the very beginning of the registration form doesn’t matter, but the home region must be chosen wisely. Some articles say that Ampere ARM shape is available on West USA servers, so I’ve picked the region in this way just in case, no confirmation on the Oracle site had been found though – the only limitation mentioned regarding South Korea and Japan.

The most annoying during the tenancy application process is the registration system itself – it can reset some data entered in the fields or miss the registration mail to send and make the applicant take all the way anew. And the two-pages-long captcha puzzle will demand to pass it several times, indeed, any field change leads to take a new attempt with captcha.

At last, the tenancy is created, and it’s time to say to the world the first “Hello!”.

The sequence of server run is based on the actions done by Mr. Rohit Rahi – Senior Director of OCI Delivery, OCI University trainer, in the framework of the Oracle Cloud Infrastructure learning course, the Compute demo section video. If you want to go deeper into OCI, the training is recommended, most of the topics are free to follow and not so boring – get to learn at http://learn.oracle.com, if the registration of another account, the general Oracle one, can not scare you too much. Anyway, it may be useful e.g. to download the latest versions of Oracle Java runtime and development tools, if you need to.

The following steps are to be done to prepare the infrastructure:

  • Deployment of the server
    • Go to the main menu (horizontal dashes on the page top left near Oracle Cloud logo) -> Compute -> Instances
    • Click the “Create instance” button
    • Provide the name for the VM-instance
    • In the Image and Shape section, the Edit link leads to the panel, where the VM-configuration and OS may be chosen. Considering the Free resource, the two mentioned above shapes are available (marked as Always Free-eligible label), all the others are to be paid. Keep Oracle Linux 7.9 as the OS image by default.
    • Important step – click Save Private Key and Save Public Key if you don’t have any. Rename the files with less complicated names (e.g. myserverkey.key and myserverkey.key.pub – this name I will use as an example further. You may generate the pair of the key-files on your own using ssh-keygen command in any Linux OS or Windows 10-11 Power Shell, refer to the manual for the command.
    • Pay attention to the Networking section, the instance can’t exist in the “networking vacuum”, it has to be placed in some Virtual Cloud Network (VCN) subnet. So, expand it for advanced options by clicking “Edit”: if you have no VCNs deployed, make sure, that to create of new VCN and new public subnet is considered and they are pointed as the placement destination. The new VCN and subnet names can be also defined here.
    • Finish the server initiation by clicking “Create”
    • Wait until the server has the status “Running” – it takes about a minute
    • Note the essential attribute of your server: the public IP address – it’s the worldwide identifier of your resource, not fancy, but unique. Assigning the domain name to make it available like any other website is beyond the scope of this article (by default the domain name is assigned, but it’s long and not so useful).
  • Connect to the server
    • As had been chosen the Oracle Linux is running on the virtual machine, which is going to serve us as the webserver, therefore the remote SSH connection is required to have access to the console and do the setup.
    • Each tenancy has access to a console provided with a background virtual machine, despite any resources deployed on the cloud. The console named “Cloud shell” can be opened with the “ >_ ” button in the top right part of the main Cloud Management page.
    • Open the console, the invitation like username@<tenancy name>:~ (<server region domain>)$ appears.
    • At first, let’s undertake some dances with ssh-keys. Open console menu (three horizontal dashes in the top left corner of Cloud Shell area) -> Upload Files -> Drag and drop the private key (myserver.key, not the .pub one) or pick it by file browsing, wait until upload complete.
    • The .key file assumes to contain restricted-access data, so it has to be protected from any unexpected actions. Therefore, the ssh demands that .key files are being stored with strict access attributes, otherwise we have a warning message WARNING: UNPROTECTED PRIVATE KEY FILE! during connection attempt and the connection will be refused. Let’s fulfill it.
    • Type in console chmod 600 myserver.key. Here is no need to use sudo – the Cloud Shell runs under root-rights-user by default. Now the myserver.key file is protected from any access except its owner actions.
    • Now it’s time to connect to the Compute instance with the public IP address (if didn’t notice, go to menu -> Compute -> Instances -> look at the Public IP field): ssh opc@<public IP address> -i myserver.key. During initial connection, the confirmation of trust of the resource is needed (type yes). After connection, the command prompt changes to [opc@<instance name>]$. OK, we’re in.
  • Setup the webserver
    • The first step is to install the webserver package. Actually said, have no clear understanding of what is happening as the command are executed, know only some kind of set based on Apache webserver is being installed. Anyway, it works: sudo yum -y install httpd
    • After the entire installation is complete, open the corresponding port in integrated firewall settings and restart it:
      • sudo firewall-cmd --permanent --add-port=80/tcp 
      • sudo firewall-cmd --reload
    • Start the webserver daemon:
      • sudo systemctl start httpd
  • And finally, there must be a home page which is to display as someone visit your site, it has to be placed in /var/www/html/index.html. The following way is enough to display any word on entering the page. If anything more expanded is expected to produce, the vim or nano or something else helps.
    • sudo su
    • echo 'Hello!'>>/var/www/html/index.html

Hard to believe, but from now if you enter the <public IP address> into the web browser address field… nothing works.

The trouble is in VCN default settings which allow the only ssh connections and keep the 22 port open. It has to be additionally configured to open HTTP inbound port (80) and make our public network segment accessible from the internet via HTTP requests:

  • Open port 80:
    • In the VCN profile (main menu -> Networking -> Virtual Cloud Networks -> <VCN name>) open “Public Subnet_<VCN name>” item
    • Choose “Security lists” in the left column
    • Open “Default security list for <VCN name>”
    • Click “Add ingress rules”
    • Fill the CIDR field with 0.0.0.0/0 (any inbound IP); Destination port: 80. Remaining fields keep unchanged, click “Add ingress rules” button in the bottom.

Now if the public IP is being addressed via a web browser the content of the index.html is shown, and “Hello!” appears.

Then the website may be developed further, so it’s the following step, not considered to be enlightened here.

If any domain name (<main domain>.<zone>) is available to be delegated, even if it’s already occupied by any other project just add the following A DNS record to the domain profile:

  • Record type: A
  • Host (subdomain): <any name>
  • Value: <public IP> – it’s from Oracle Cloud compute instance profile
  • TTL: 21600 (default value)

Then the address <any name>.<main domain>.<zone> leads to that Oracle Cloud-powered website. e.g. my cloud exercise is hosted at sandbox.yogene.ru.

This entry was posted in cloud cervices, HTML, OCI, web. Bookmark the permalink.