Code Monkey home page Code Monkey logo

loadbalance-nodejs-nginx-1's Introduction

loadbalance-nodejs-nginx-1

How to control the backend traffic of web application we serve using Nginx

This is a simple application that uses Nginx as a load balancer to control traffic comming from the client to node.js backend servers

Getting Started

To get started with this project you need to have docker installed on your system

  1. Clone the repository

git clone https://github.com/OpenTechConsult/loadbalance-nodejs-nginx-1.git

  1. Navigate to the project directory

cd loadbalance-nodejs-nginx-1

  1. Navigate to the server directory

cd server

  1. build the image

docker built -t server .

  1. create a network for all the future running containers to share.

docker network create loadbalance_net

  1. run 4 containers as follow

docker run -p 1010:5050 --name backend_server_1 -d --network loadbalance_net server

docker run -p 2020:5050 --name backend_server_2 -d --network loadbalance_net server

docker run -p 3030:5050 --name backend_server_3 -d --network loadbalance_net server

docker run -p 4040:5050 --name backend_server_4 -d --network loadbalance_net server

  1. After that cd into the nginx folder

cd nginx

  1. Build the image inside the docker file

docker build -t nginx_load_balancer .

  1. run the nginx container

docker run -p 3000:80 --name nginx_server -d --network loadbalance_net nginx_load_balancer

  1. You can the test our loadbalanced application by sending a request to http://localhost:3000

We will get a response saying

This is the server's response

loadbalance-nodejs-nginx-1's People

Contributors

opentechconsult avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.