Skip to content

biprajit007/ansible_project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Nginx Load Balancer Setup with Ansible

This repository contains an Ansible playbook designed to automatically configure an Nginx Load Balancer, distributing incoming HTTP requests evenly across five backend web servers.


πŸ“Œ Overview

The provided Ansible playbook handles:

  • βœ… Installation of Nginx on the designated load balancer host.
  • βœ… Automated Nginx configuration as a reverse-proxy load balancer.
  • βœ… Efficient load distribution among five backend servers.

πŸš€ Project Structure

nginx-loadbalancer-ansible/
β”œβ”€β”€ hosts                      # Inventory of servers
β”œβ”€β”€ loadbalancer.yml           # Main Ansible playbook
└── templates
    └── nginx_lb.conf.j2       # Nginx configuration template

πŸ”§ Requirements

Ensure the following prerequisites are met:

  • Ansible installed on your local control machine:
sudo apt install ansible
  • SSH key-based authentication configured on all remote hosts.
  • Ubuntu/Debian-based Linux servers for load balancer and backend hosts.

βš™οΈ Configuration Steps

Update the hosts file to reflect your server IP addresses or domain names:

[loadbalancer]
lb.example.com ansible_host=192.168.1.10

[webservers]
web1.example.com ansible_host=192.168.1.21
web2.example.com ansible_host=192.168.1.22
web3.example.com ansible_host=192.168.1.23
web4.example.com ansible_host=192.168.1.24
web5.example.com ansible_host=192.168.1.25

▢️ Running the Playbook

Run the following command to deploy the load balancer:

ansible-playbook -i hosts loadbalancer.yml

πŸ§ͺ Testing the Setup

Test your load balancer by navigating to:

http://<loadbalancer-ip-address>/

You should see the load balancing in action across your backend servers.

About

Ansible Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages