Skip to content

anav5704/nginx-load-balancer

Repository files navigation

Nginx Load Balancer

This is a simple Nginx load balancer that runs against 3 Docker containers. Each container runs a simple Hono.js server on port 3000, while Docker compose is used to map these ports to 3001, 3002 and 3003. This load balancer is deployed on Oracle Cloud using Terraform to provision a VM and Ansible to configure the VM.

Architecture Diagram

Technologies Used

Getting Started

Make sure you have Nginx and Docker installed on your machine.

Build and Start Containers

First, build and start the containers using docker-compose:

docker-compose up --build -d

Configure Nginx

Next, you need to replace the default nginx.conf on your machine with the one provided in this here. This file should be located at C:/nginx/conf/nginx.conf on Windows and /etc/nginx/nginx.conf on MacOS.

Then, start up Nginx on Windows using:

cd path/to/nginx
nginx.exe

Or this if you're on a Mac:

sudo nginx

Access Load Balancer

Finally, open your browser and go to http://localhost:8080 to see the response. Each time you refresh, the server that sends the response will change.

Learning Resources

About

Nginx load balancer running against 3 containers using Docker Compose

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published