Lab 14‐1 ‐ HAProxy Load Balancer - Isaiah-River/NET-330-01-Network-Design GitHub Wiki

To start this lab, I downloaded two base VMs. I then copied the CentOS-apache-base VM so that I would be able to have two VMs. I then opened each of these within VMware Workstation, and powered them on. I renaming the copies to VMs to Server 1 and Server 2. On each of these I ran the dhclient command to get an IP address. I then ran ip addr to show my IP address, and ensured that the two servers had connectivity.

{7DCD62B8-29BC-44A4-A772-B80A0A5EEAAE}

{8F84AC06-CA7B-4074-A6EB-4B6065E4207D}

Once confirming I could ping across these VMs I created an index file with my name and server number within /var/www/html, and started each of their apache servers by running the systemctl start httpd command, and ensured that my workstation could navigate to these addresses:

{F03AF278-54DB-4ABC-8ECB-93B2E3AAF344}

{3C9E845F-35FF-4469-806E-2E1F511F4205}

I then booted up the HA Proxy VM and logged in, and ran the dhclient command to pull an IP address. I then pinged the web servers to ensure I was able to reach them.

{53FF7D33-8C1C-475C-8B4E-1AC55C5DD390}

I then ran the following commands: vi /etc/haproxy/haproxy.cfg

{55D5071F-1753-4EF5-896A-3E93A4B626A3}

{69D22BA1-2AAD-4F4C-B27C-1115CBC7B5AB}

I then navigated to the HA proxy address, where I was directed to a Server1, and refreshing brought me to Server2

{A25E5B1E-80DD-4432-BE09-7C0C389CC197}

vi /etc/rsyslog.conf

{FB8F7757-D486-4D27-80CB-9BA873FBD856} {B57DF0E7-7371-4E4F-B36C-E44AD14CBB5A}

systemctl restart rsyslog

I then ran the command tail -f /var/log/haproxy.log to pull the logs, which showed nothing, I then refreshed my connection to the front end a couple of times, and reran the command:

{FB249D69-0DF0-4402-A5B3-51030C4C6337}

vi etc.haproxy/haproxy.cfg

Add check after servers:

{88FAB75A-A342-4D92-9273-7DADB3CA798C}

systemctl restart haproxy
tail -f /var/log/haproxy.log

I then shutdown server 2 and waited for the response

{316E746A-0D24-4C5F-ABC6-CDA68E0EAF14}

I then booted it up and ran dhclient and systemctl start httpd again. This was logged with the server coming back up:

{85E4FE3B-3CE5-4492-8BA7-EB0117E74163}

On server 1 and server 2:

sudo vi /etc/httpd/conf/httpd.conf

{03B69133-0B3A-46DA-9132-C2EFD34E265B}

on HA proxy:

vi /etc/haproxy/haproxy.cfg

{52B3909B-EC9D-4E27-B5F8-94BB966B0533}

systemctl restart haproxy

On web servers

sudo firewall-cmd --zone=public --add-port=8008/tcp --permanent
sudo firewall-cmd --reload

I then ensured I could connect to that server on port 8008 directly:

{C4ED437D-9B43-48C8-9B20-9E7571672AAC}

As well as connect to the front end: {25636D11-E40A-4C74-B03D-3F3A7DB403A3}

on HA proxy:

vi /etc/haproxy/haproxy.cfg

{0684B2DC-4299-4EAC-B5C4-79B1E9123741}

tail -f /var/log/haproxy.log

On web serv2 mv /var/www/html/index.html mv /var/www/html/index2.html mv /var/www/html/index2.html /var/www/html/index.html

{821F2CAB-705C-487C-B4EF-94EE06D5DE84}