Creating backend servers – Configuring Load Balancing
Creating backend servers
Now, we need to set up the backend servers. We are going to create two VMs that are going to be used as backend servers for the load balancer. We are also going to install NGINX (which is an open source, high-performance HTTP server, and reverse proxy) onthem to test the load balancer:
- We are going to create two VMs with NGINX installed on them and create a Hello World Node.js app on the Linux VMs. For this, we need to create a file called cloud-init.txt and paste the configuration into it. The following cloud-init configuration installs all the required packages, then creates the Hello World app, and then starts the app. To create the cloud-init.txt file, paste the following line:

2. Paste in the following configuration code. The first part under packages: adds the packages:

3. The next part sets up the server; paste this into the editor:

4. The next part creates the app; paste this in the editor too:

5. And the final part that you paste will run the app:

6. With the preceding blocks of code, we have now created the cloud-init.txt file for our VMs. Save the file in the editor by pressing Ctrl + X. Press Y and Enter on your keyboard; this will save and exit the editor.
7. Now, we can continue with creating the two VMs and apply the configuration on them, as follows:

Now that your backend servers are in place, they are ready to be used, so let’s run through some testing next to confirm that all is operational as expected. Please give your servers about 5 to 10 minutes to provision before moving to the next step.