Building modern web applications-Part 1

Stage: 1 – Building a three-tier web application on Google Cloud


The intent of this tutorial is getting comfortable with the app dependency flows of modern applications in the cloud and how to migrate flawlessly to the latest container based and serverless technologies.

Application has always been the focal point in the enterprise datacenter.Even with all latest trending technologies which are gaining prominence on a daily basis , the end result expected is same from all tools and platforms.Building the better application and augment business strategies.

Three tier app model has been around for long and it has server application really well.

In this tutorial as part of stage -1.

Infrastructure setup has nginx configured as a reverse proxy,node.js application which will serve as an app server and a MySQL database server.

Data flow happens like this.

[Nginx(Ubuntu 16.04) —>node.js (Ubuntu 16.04)—>mysql(Ubuntu 16.04)].

Entire setup will run on Google Cloud Compute Engine.Create web server ubuntu vm using google cloud management interface.

or using a simple gcloud command line.

gcloud compute instances create example-instance-1 example-instance-2 example-instance-3 --zone us-central1-a

Configuring nginx as reverse proxy

root@web01:~#apt-get update
root@web01:~#apt-get install nginx

This will get nginx installed

root@webserver:~# service nginx status
● nginx.service -- A high-performance web server and a reverse proxy server
  Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
  Active: active (running) since Sat 2017-09-23 11:30:28 UTC; 2min 23s ago
 Process: 1522 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Process: 1398 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 1542 (nginx)
   Tasks: 2
  Memory: 10.3M
     CPU: 27ms
  CGroup: /system.slice/nginx.service
          ├─1542 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
          └─1545 nginx: worker process                           
Sep 23 11:30:27 webserver systemd[1]: Starting A high-performance web server and a reverse proxy server…
Sep 23 11:30:28 webserver systemd[1]: Started A high-performance web server and a reverse proxy server.

Create a reverseproxy.conf file

root@webserver:/etc/nginx/sites-available# touch reverseproxy.conf
root@webserver:/etc/nginx/sites-available# cat reverseproxy.conf
http {
   upstream backend {
       server backup;
   server {
       location / {
           proxy_pass http://backend;

Configuration for reverse proxy in nginx is quite simple.configure the number of backend server with the port with which it has to connect to them in the configuration file

Create a simlink to /etc/nginx/sites-enabled .This will make nginx refer the configuration file and forwards the traffic accordingly.

root@webserver:/etc/nginx/sites-available# ln -s /etc/nginx/sites-available/reverseproxy.conf /etc/nginx/sites-enabled/reverseproxy.conf
root@webserver:/etc/nginx/sites-available#service nginx restart


Posted in Uncategorized.

Leave a Reply

Your email address will not be published. Required fields are marked *