Introduction:
This guide provides step-by-step instructions on how to set up an Anycast Load Balancer on Ubuntu 22.04 LTS using Apache with BinaryLane.
For information on our Load Balancer, see here: Load Balancer | BinaryLane
Prerequisites:
- A BinaryLane Account
- At least two Ubuntu 22.04 LTS Servers with Apache installed
- Access to the BinaryLane control panel (mPanel)
Step 1: Sign Up for Load Balancer Service
- Log into your BinaryLane Account
- Navigate to the Load Balancer section within mPanel and sign up for the Load Balancer service
Step 2: Configuration in mPanel
- Under `Services`, select `Manage` for the Load Balancer you wish to configure.
- On the `Manage Load Balancer` page, under `Servers` ☛ `Virtual Server`, select your Ubuntu VPS from the drop-down box, then click `add`. (Note: You'll need to repeat this step for each server you wish to configure to receive traffic through the Load Balancer.)
- Provide a hostname for your Load Balancer, specify the path if required, and ensure to select the correct protocol (HTTP/HTTPS).
Ubtunu Configuration:
Step 3: Update and Install Necessary Packages
- Perform the following commands:
sudo apt update sudo apt install
Step 4: Configuring Network Settings
Important
Without disabling the cloud-init network config, the netplan configuration will revert upon restarting your server. To disable the network configuration file, create a new network-config disabling configuration in `/etc/cloud/cloud.cfg.d/99-disable-network-config.cfg` with the following content:network: {config: disabled}
- Reboot and login to your server.
- List netplan configuration files:
sudo ls /etc/netplan/
- Open the `.yaml` file for editing (replace `xx-cloud-init.yaml` with your filename):
sudo nano /etc/netplan/xx-cloud-init.yaml
- Update the file with the following configuration changes, replacing IP addresses and other values with your own:
. . . eth0: addresses: - 112.213.38.164/24 # Primary IP (Public/Primary IP Addr.) - 103.17.56.142/32 # Virtual IP (Anycast IP of your Load Balancer) - 172.22.27.250/16 # LAN IP gateway4: 112.213.38.1 # Gateway for your Public/Primary IP Addr. . . .
- Apply the network configuration:
sudo netplan apply
Step 5: Configuring Apache
- Install Apache:
sudo apt-get install -y apache2
- Start and enable Apache:
sudo systemctl start apache2 sudo systemctl enable apache2
- Create a directory for your site:
sudo mkdir -p /var/www/html/test-site
- Create and edit site configuration file for Apache:
sudo nano /etc/apache2/sites-available/test-site.conf
- Add the following configuration to the file:
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName yourdomain.com DocumentRoot /var/www/html/test-site ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Note: This configuration will only enable HTTP traffic. For configuring HTTP + HTTPS traffic, you must create an additional VirtualHost block for port 443 with the necessary SSL configurations. For example:<VirtualHost *:443> ServerAdmin webmaster@localhost ServerName yourdomain.com DocumentRoot /var/www/html/test-site ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined SSLEngine on SSLCertificateFile /etc/letsencrypt/live/yourdomain.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/yourdomain.com/privkey.pem # Optionally use the below line for a strong SSL configuration # Include /etc/letsencrypt/options-ssl-apache.conf </VirtualHost>
Support:
If you encounter any issues with the health checks, ensure that your site/server is configured to receive the HTTP/HTTP+HTTPS/HTTPS traffic from Port 80 for HTTP and port 443 for HTTPS (Review step 5.5). You can test this by listening for traffic on your web server whilst browsing your newly configured site.
If you're unable to install Apache + Bird and you're encountering an issue similar to this;
Could not connect to mirror.binarylane.com.au:80 (103.17.56.131). - connect (113: No route to host)
Review your netplan configuration. Ensure that your CIDR block for your Virtual IP Address is set to /32
For any other problems, refer to the troubleshooting section in the BinaryLane documentation or submit a ticket
For any other problems, refer to the troubleshooting section in the BinaryLane documentation or submit a ticket
For any other problems, refer to the troubleshooting section in the BinaryLane documentation or submit a ticket