Deployed a simple Web Application by NGINX  through Shell Scripts and Handling Errors🚀🌐

Deployed a simple Web Application by NGINX through Shell Scripts and Handling Errors🚀🌐

NGINX (pronounced "engine x") is open-source software that works as a web server, reverse proxy, load balancer and HTTP cache. It's built for high performance and reliability. Besides serving web content, NGINX handles HTTPS connections and can also manage email protocols like IMAP, POP3 and SMTP.

Things nginx usually does for us

Web Server : NGINX can serve website files and automatically list directory contents.

Reverse Proxy : NGINX can direct web traffic to different servers and provide security and caching to improve performance.

Load Balancer : NGINX can split web traffic between different servers to balance the load.

Mail Proxy : NGINX can handle email traffic using protocols like IMAP, POP3 and SMTP.

HTTP cache : NGINX can store copies of web pages for faster access and to reduce the load on the server.

Prerequisites are - Having a running vm on any cloud provider.

Lets Begin to serve a basic django-notes-webapp project,,,

Step 1 : Update and Install the Nginx.

$ sudo apt-get update && install nginx -y

Step 2 : Clone the repository from github to vm server.

$ git clone https://github.com/rksdutt/django-notes-app.git

Step 3 : Navigate inside of this cloned django-notes-app directory & install docker.io

$ sudo apt-get docker.io -y

Step 4 : Give permission to the USER to access docker and add the USER to the docker's group. After giving the permission we need to reboot out system so that docker can acknowledge the USER.

$ sudo usermod -aG docker $USER
$ sudo reboot

Step 5 : Now it's time to docker build a docker image to run our web app. To build the docker image run this...

$ docker build -t rakeshdutt/notes-app .

Step 6 : After build the image now we have to run our to deploy the our web-app.

$ sudo run -d -p 8000:8000 rakeshdutt/notes.app:latest

Step 7 : Here we have to see the outpur we've worked on. So on the terminal we run this..

$ docker ps

Here we can see our application is running.

Step 8 : Here we have to check our backend & our api running or not through this command if this is running then we need to add proxy_pass on nginx default folder.

$ curl -L http://127.0.0.1:8000
& 
$ curl -L http://127.0.0.1:8000/api

Step 9 : Here we are adding proxy_pass on default cause application api should not face any route missing thats why we need add proxy_pass. So as on we have to change our nginx configuration little bit mean we need add some on /etc/nginx/sites-enabled forlder called default on location we just add proxy_pass with ip of local and port expose 8000.

Step 10 : We simply save this configuration file after making changes. Here we need to restart our nginx again cause we make something change with the configuration file with this command...

$ sudo systemctl restart nginx.service

Step 11 : Last thing is we need to check our web app running on public ip with exposing port 8000:8000. So pick the public ip from our instance and run it on search engine with exposing port. And here we go the web applicaton running successfully save the notes as well.

Here is the end of our deployment of a simple web application with nginx. I Personally leaving my Gratitude for Shubham Londhe for such project and live debugging.

Did you find this article valuable?

Support dailydoseindevops by becoming a sponsor. Any amount is appreciated!