vault backup: 2024-12-12 19:30:24

This commit is contained in:
sShemet
2024-12-12 19:30:24 +05:00
parent 55bb5f0502
commit c39a763a5f
8 changed files with 134 additions and 9 deletions

View File

@@ -0,0 +1,52 @@
Load balancing is a critical component in any high-availability web infrastructure. It helps distribute traffic across multiple servers, ensuring no single server bears too much load and potentially enhancing the performance and reliability of your applications. HAProxy, which stands for High Availability Proxy, is a popular open-source load balancer and proxy server for TCP and HTTP-based applications. This guide will walk you through setting up a load balancer using HAProxy on Debian 12.
## Prerequisites
- A Debian 12 server with root access or a user with sudo privileges
- At least two backend servers to distribute the load to
- Basic understanding of Linux command line and networking concepts
## Step 1: Installing HAProxy
First, update your package index and install HAProxy:
```sh
sudo apt update
sudo apt install haproxy -y
```
## Step 2: Configuring HAProxy
Edit the HAProxy configuration file located at `/etc/haproxy/haproxy.cfg` using your preferred text editor. The following snippet shows how to set up a basic load balancing for HTTP traffic:
```sh
frontend http_front
bind *:80
stats uri /haproxy?stats
default_backend http_back
backend http_back
balance roundrobin
server server1 backend1.example.com:80 check
server server2 backend2.example.com:80 check
```
The configuration directs traffic on port 80 to the backend servers in a round-robin fashion. The `stats uri` line enables HAProxy statistics report at the given URI.
## Step 3: Starting HAProxy
After configuring HAProxy, start the service and enable it to run on boot:
```sh
sudo systemctl start haproxy
sudo systemctl enable haproxy
```
## Step 4: Verifying the Configuration
To verify that HAProxy is running and configured correctly, you can navigate to `http://your_server_ip/haproxy?stats` in your web browser. You should see the HAProxy statistics page, which displays the status of your backend servers.
## Conclusion
With HAProxy installed and configured on your Debian 12 server, you've set up a basic load balancer that can help improve the availability and reliability of your web applications. Remember to customize the HAProxy configuration to suit your specific needs and environment. If managing infrastructure is not your forte or you're looking to expand your team, consider the option to [hire remote DevOps engineers](https://reintech.io/hire-remote-devops-engineers) who can help you optimize and scale your environment efficiently.

View 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. 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
```
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]]