1.7 KiB
1.7 KiB
Load Balancer is a solution to stabilize traffic in the Network. Load Balancer works by distributing traffic to ensure servers are not overloaded.
We can use a load balancer using Debian 11 (bullseye). in this example topology using 2 Web Servers.
- First Step, We must install OS Debian 11 as Load Balancer
- Don’t forget to update and upgrade OS
- Login as Super User (root)
root@loadbalancer:/home/aji# apt-get update
root@loadbalancer:/home/aji# apt-get upgrade
- Install HAProxy
root@loadbalancer:/home/aji# apt-get install haproxy
- Configure HAProxy in the file config “etc/haproxy/haproxy.cfg”
root@loadbalancer:/home/aji# nano /etc/haproxy/haproxy.cfg
- Add Command to define Web Servers
# Define frontend
frontend apache_front
# Frontend listen port - 80
bind *:80
# Set the default backend
default_backend apache_backend_servers
# Enable send X-Forwarded-For header
option forwardfor
# Define backend
backend apache_backend_servers
# Use roundrobin to balance traffic
balance roundrobin
# Define the backend servers
server backend01 192.168.77.84:80 check
server backend02 192.168.77.85:80 check
- Restart HA Proxy
root@loadbalancer:/home/aji# systemctl restart haproxy
- Testing for ensure working normally to access to the Load Balancer (HAProxy)
