Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/protik111/load-balancer-nginx-docker
A simple load balancer with nginx that serves the request into two servers that are running on docker container.
https://github.com/protik111/load-balancer-nginx-docker
Last synced: about 4 hours ago
JSON representation
A simple load balancer with nginx that serves the request into two servers that are running on docker container.
- Host: GitHub
- URL: https://github.com/protik111/load-balancer-nginx-docker
- Owner: Protik111
- Created: 2024-07-06T17:06:51.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-23T09:40:24.000Z (3 months ago)
- Last Synced: 2024-08-24T03:47:13.176Z (3 months ago)
- Language: Shell
- Homepage:
- Size: 98.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# load-balancer-nginx-docker-v1
![Architecture Diagram](./HLD/system.png)# Dockerized Node.js Project with Nginx Load Balancing
This project demonstrates how to Dockerize a Node.js application and set up Nginx as a load balancer to distribute traffic among multiple Node.js containers.
## Prerequisites
Make sure you have Docker installed on your machine. You can download and install Docker from [Docker's official website](https://www.docker.com/get-started).
## Project Structure
- **app.js**: Node.js application file.
- **Dockerfile**: Dockerfile for building the Node.js application image.
- **nginx.conf**: Custom Nginx configuration file for load balancing.## Setup Instructions
### Step 1: Create Docker Network
Create a Docker network named `internal` to allow communication between containers:
```bash
docker network create internal
docker build -t my-node-app .docker run -d --name node-app --network internal -p 4000:4000 my-node-app
docker run -d --name node-app2 --network internal -p 4001:4000 my-node-app
# Add more instances as needed, adjusting ports accordingly
docker run -d --name nginx --network internal -p 80:80 nginx:latestdocker cp ./nginx.conf nginx:/etc/nginx/conf.d/default.conf
docker restart nginx