Load Balancing Lab - echadbourne/NET-330 GitHub Wiki

I downloaded each of the VMs, fired up the centos ones, and gave them IP addresses. they were able to ping between each other so I made almost identical pages on them, with the number being different on the respective server

{168B4A87-9091-45EA-893C-9B49A0B5FA2A}

{88E8A4AC-C9B5-4239-9F75-58FBD3988AD1}

I then started the httpd service on both of them with sudo systemctl start httpd

For the haproxy server, I started it, ran dhclient to get it an ip address, pinged the other servers, and then edited the /etc/haproxy/haproxy.cfg file to say the following:

{ED22445F-4215-4B70-9E6F-CDD85F36BF96}

I then restarted the service, and went to the ip address of the load balancer, and each of my servers were showing there

{BF4C8FDA-016D-4668-B0C7-5B3CA5BC67F5}

{5B2A8986-39D3-4613-9A0D-43FBBB79EC9E}

{480299FF-ED4D-4513-906B-CDEB8FCB15D1}

Logging

In /etc/rsyslog.conf I made the following changes:

image

I also restarted haproxy, and did a tail -f /var/log/haproxy.log to see the server connections. Here are the logs:

{385EB432-7E88-40F5-A232-0EEDDCF78A79}

Health Checks

Go to the /etc/haproxy/haproxy.cfg

Add check after the server definitions

{AAD2CC8F-015D-46B3-8257-AB0ADCEAF505}

Watch the logs and turn things on and off - both the server, and the service

{A1BB6302-37B8-4C39-A6C6-4F8E6FBB3231}

Additional Configurations

Go to /etc/httpd/conf/httpd.conf on each of the servers and change the listening port to 8008

Change the port in haproxy

{4AD02038-20F2-4899-ACE3-81F7E41250CD}

On the servers allow port 8008 with firewall-cmd --add-port=8008/tcp

Restart both httpd on both servers and haproxy

Add a line to do a HEAD check on a certain url (note, the host field is required but is not used in this case and does not need to be the server its checking)

{A0BEADEE-5FA6-4C35-A43D-53F8BC8959FF}

restart haproxy

Layer 7 down and up log

{B70B395C-DE9F-4443-BFFC-73885ECC6A12}