vault backup: 2024-12-12 19:30:24
This commit is contained in:
66
WORK & PROJECTS/Mol/Серверы/DOCS/Load Balancer.md
Normal file
66
WORK & PROJECTS/Mol/Серверы/DOCS/Load Balancer.md
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
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. Don’t 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
|
||||
```
|
||||
|
||||
4. Install HAProxy
|
||||
|
||||
```
|
||||
root@loadbalancer:/home/aji# apt-get install haproxy
|
||||
```
|
||||
|
||||
5. Configure HAProxy in the file config “etc/haproxy/haproxy.cfg”
|
||||
|
||||
```
|
||||
root@loadbalancer:/home/aji# nano /etc/haproxy/haproxy.cfg
|
||||
```
|
||||
|
||||
6. 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
|
||||
```
|
||||
|
||||
|
||||
7. Restart HA Proxy
|
||||
|
||||
```
|
||||
root@loadbalancer:/home/aji# systemctl restart haproxy
|
||||
```
|
||||
|
||||
8. Testing for ensure working normally to access to the Load Balancer (HAProxy)
|
||||
|
||||
|
||||
![[Pasted image 20241212175851.png|Server1]]
|
||||
|
||||
|
||||
![[Pasted image 20241212175929.png|Server2]]
|
||||
Reference in New Issue
Block a user