Ech0 - 00 / 00 / 00

Haproxy setup

This one is done from proxmox, i used a debian10+ CT template to create the machines i needed.

Initial setup

To start with, get 2 identical debian hosts with nginx on them:

My 2 servers will have the ips 192.168.0.151 and 192.168.0.150 meanwhile 192.168.0.152 is going to be our haproxy server.

First server:

apt update -y && apt upgrade -y
apt install nginx curl -y
echo 'server number 1' > /var/www/html/index.nginx-debian.html
ip a | grep inet	#IP1

Second server:

apt update -y && apt upgrade -y
apt install nginx curl -y
echo 'server number 2 ' > /var/www/html/index.nginx-debian.html
ip a | grep inet	#IP2

Now that we have 2 servers running http, we're going to load balance them with a third debian machine with haproxy:


apt update -y  && apt upgrade -y
apt install haproxy curl -y
wget https://ech1.github.io/blog/servers/haproxy/haproxy.cfg -O /etc/haproxy/haproxy.cfg
nano /etc/haproxy/haproxy.cfg 
systemctl restart haproxy
ip a | grep inet	#IP3
curl 127.0.0.1

In nano, change the ips with the ips of your 2 debian servers (IP1 & IP2) and reload haproxy, then go and see if haproxy works (IP3)

You can reload haproxy's webpage multiple times, and you'll see that sometimes it is going to switch from one server to the other, therefore we successfully setup a simple load balancing with haproxy.

2




	

	

	

3




	

	

	

My Bunker

Some Address 67120,
Duttlenheim, France.

About Ech0

This cute theme was created to showcase your work in a simple way. Use it wisely.