We will be using servers we configured for our tooling website which consists of:
- Two RHEL8 Web Servers
- One MySQL DB Server (based on Ubuntu 20.04)
- One RHEL8 NFS server
- Set up a new Ubuntu server on EC2.
- Install Apache Load Balancer on the server and configure it to point traffic coming to Load Balancer to both Web Servers:
# Install apache2
sudo apt update
sudo apt install apache2 -y
sudo apt-get install libxml2-dev
# Enable the following modules:
sudo a2enmod rewrite
sudo a2enmod proxy
sudo a2enmod proxy_balancer
sudo a2enmod proxy_http
sudo a2enmod headers
sudo a2enmod lbmethod_bytraffic
- Restart apache2 service
sudo systemctl restart apache2
- Make sure apache is running
sudo systemctl status apache2
sudo vi /etc/apache2/sites-available/000-default.conf
- Add this configuration between section
<VirtualHost *:80>
and</VirtualHost>
section:
<Proxy "balancer://mycluster">
BalancerMember <WebServer1-Private-IP-Address>:80 loadfactor=5 timeout=1
BalancerMember <WebServer2-Private-IP-Address> loadfactor=5 timeout=1
roxySet lbmethod=bytraffic
# ProxySet lbmethod=byrequests
</Proxy>
ProxyPreserveHost On
ProxyPass / balancer://mycluster/
ProxyPassReverse / balancer://mycluster/
- Verify that our configuration works by accessing our LB’s public IP address or Public DNS name from the web browser
- Remember we mounted /var/log/httpd/ from our Web Servers to the NFS server in our tooling project - unmount them and make sure that each Web Server has its own log directory.
sudo umount -l <WebServer-Private-IP-Address>:/mnt/logs
- Open two ssh consoles for both Web Servers and run following command:
sudo tail -f /var/log/httpd/access_log