https://github.com/pratikshinde55/loadbalancer-haproxy-aws
Creating HAProxy Load Balancer and Register Backend to LB (/etc/haproxy/haproxy.cfg) on the top of AWS Cloud.
https://github.com/pratikshinde55/loadbalancer-haproxy-aws
aws-ec2 bind haproxy-loadbalancer load-balancer round-robin-algorithm
Last synced: about 1 month ago
JSON representation
Creating HAProxy Load Balancer and Register Backend to LB (/etc/haproxy/haproxy.cfg) on the top of AWS Cloud.
- Host: GitHub
- URL: https://github.com/pratikshinde55/loadbalancer-haproxy-aws
- Owner: Pratikshinde55
- Created: 2024-02-28T14:05:20.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-26T12:15:23.000Z (about 1 year ago)
- Last Synced: 2025-01-13T16:50:33.144Z (about 1 year ago)
- Topics: aws-ec2, bind, haproxy-loadbalancer, load-balancer, round-robin-algorithm
- Homepage:
- Size: 53.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Load-Balancer Set-up on the AWS Cloud using HAproxy LB:

Load balancer distribute workload and improve website and application performance.
load balancer distribute incomming application traffic across multiple backend(target).load balancer also called as Frontend or reverse proxy.
## Haproxy:-
HAproxy is one of the product of load balancer, HAproxy is a high-performance, open source load balancer & reverse proxy for HTTP and TCP .
- Set-up:
For Loadbalancer setup I launched 4 AWS EC2 Instances One Instance make Load Balancer(Frontend),and remaining
three make Backend, In my case named as Backend-1 (ip-172-31-44-4) ,Backend-2 (ip-172-31-33-138),Backend-3(ip-172-31-40-19).


## Step:1- [Backend Configuration(Web server)]
On three Backend instances, configure following same set-up as it is on each backend nodes:
1. Install httpd php software(Apache):
yum install httpd php -y
2. DocumentRoot for "Apache server is /var/www/htmt" Create here one code folder which is access for client. here put Webpage named as index.php:
cd /var/www/html
Create index.html Webpage:
vim index.php
code:-
3. Start the httpd service:
systemctl enable httpd --now

## Step:2- [Load Balancer configuration]
1. Install HAproxy load balancer in frontend instance.
yum install haproxy -y
2. Registration of Backend to Load Balancer, HAproxy config file "/etc/haproxy/haproxy.cfg" where add backend node and also add port number which can helps to client to access the Application.
for this do follow setup:
vim /etc/haproxy/haproxy.cfg
ADD this code in config file:

- Note:
here we use Round Robin Algorithm that work as client will connect to web server through Load
balancer , 1st connect to web 1 then web 2 and next web 3 then again go to 1.
here also bind the port no. as 8080 .
3. Start HAproxy service and check status:
systemctl restart haproxy
systemctl start haproxy
systemctl status haproxy
4. Check HAproxy config file is valid or not:
haproxy -f haproxy.cfg -c
## Step:3- [Access LoadBalancer from Browser]
Now loadbalancer configuration is done.
Load Balancer(Frontend) instance change Inbound rule - allow all traffic Anywhere
Check Load balancer on browser:
Public IP of LB + port no. (http://65.0.18.65:8080)
Also on local command prompt -->>(curl http://65.0.18.65:8080)


