https://github.com/anav5704/nginx-load-balancer
Nginx load balancer running against 3 containers using Docker Compose
https://github.com/anav5704/nginx-load-balancer
ansible docker gitlab-ci honojs nginx oracle-cloud terraform
Last synced: about 2 months ago
JSON representation
Nginx load balancer running against 3 containers using Docker Compose
- Host: GitHub
- URL: https://github.com/anav5704/nginx-load-balancer
- Owner: anav5704
- Created: 2024-11-20T09:31:28.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-02-16T02:24:13.000Z (3 months ago)
- Last Synced: 2025-02-16T02:28:21.184Z (3 months ago)
- Topics: ansible, docker, gitlab-ci, honojs, nginx, oracle-cloud, terraform
- Language: TypeScript
- Homepage:
- Size: 65.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Nginx Load Balancer
This is a simple Nginx load balancer that runs against 3 Docker containers. Each container runs a simple [Hono.js](https://hono.dev) 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.

## Technologies Used
- Nginx
- Docker
- Docker Compose
- Hono JS
- Terraform [view source](https://github.com/anav5704/learning-terraform)
- Ansible [view source](https://github.com/anav5704/learning-ansible)## Getting Started
Make sure you have [Nginx](https://nginx.org) and [Docker](https://docker.com) installed on your machine.
### Build and Start Containers
First, build and start the containers using `docker-compose`:
```sh
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](https://github.com/anav5704/learning-ansible/blob/main/config/nginx.conf). 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:
```sh
cd path/to/nginx
``````sh
nginx.exe
```Or this if you're on a Mac:
```sh
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
- [What is Nginx?](https://youtu.be/iInUBOVeBCc?si=HgCJSpQSdJ7u2gEP)
- [Nginx with Docker](https://youtu.be/q8OleYuqntY?si=xjgTwVrMyM8DginP)
- [Docker crash course](https://youtu.be/pg19Z8LL06w?si=7v0qYUgNuhGS1wmn)