Files
SergObsidian/SKILLS DOCS/DOCS/Load Balancer.md
2025-05-13 10:35:25 +05:00

1.7 KiB
Raw Blame History

https://medium.com/@ajibudiono04/basic-configuration-load-balancer-using-debian-11-bullseye-c0da7047f426

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.

!Pasted image 20241212175419.png

  1. First Step, We must install OS Debian 11 as Load Balancer
  2. Dont forget to update and upgrade OS
  3. Login as Super User (root)
root@loadbalancer:/home/aji# apt-get update  
root@loadbalancer:/home/aji# apt-get upgrade
  1. Install HAProxy
 root@loadbalancer:/home/aji# apt-get install haproxy
  1. Configure HAProxy in the file config “etc/haproxy/haproxy.cfg”
root@loadbalancer:/home/aji# nano /etc/haproxy/haproxy.cfg
  1. 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  
  1. Restart HA Proxy
root@loadbalancer:/home/aji# systemctl restart haproxy
  1. Testing for ensure working normally to access to the Load Balancer (HAProxy)

!Pasted image 20241212175851.png

!Pasted image 20241212175929.png