Setup and install HAProxy community edition on Ubuntu 24.04 in Azure, AWS or GCP. Deploy straight from any of the cloud marketplaces below. HAProxy (High Availability Proxy) is a high-performance TCP/HTTP load balancer and proxy server that helps distribute traffic across multiple backend servers.
Cloud HAProxy on Ubuntu 24.04
HAProxy on Azure
Deploy HAProxy on Ubuntu 24.04 in Azure
HAProxy on AWS
Coming soon…
HAProxy on GCP
Coming soon…
Getting Started with HAProxy
Once your HA Proxy server has been deployed, the following links explain how to connect to a Linux VM:
frontend http_front: This defines the frontend (the client-facing side). It listens on port 80 for HTTP traffic.
backend web_servers: This defines the backend servers, which are the actual web servers serving the content. The balance roundrobin distributes the traffic evenly between web1 and web2.
Save the changes and exit the editor (in nano, you can do this by pressing CTRL + X, then Y, and ENTER).
Restart HAProxy
After modifying the configuration file, restart HAProxy to apply the changes:
sudo systemctl restart haproxy
Test Your HAProxy Setup
With HAProxy configured, traffic to your server’s public IP on port 80 will be routed to the backend web servers.
Visit the public IP of your HAProxy server in a web browser:
http://your-haproxy-ip
You should be directed to one of your backend servers. If you refresh the page, you’ll see traffic routed to the other server (depending on your load-balancing policy).
HAProxy Stats (Optional)
HAProxy provides a web interface for monitoring traffic and the health of backend servers.
Add the following section to your haproxy.cfg to enable the stats page:
listen stats
bind *:8080
stats enable
stats uri /haproxy?stats
stats refresh 10s
stats admin if LOCALHOST
Save the changes and restart HAProxy:
sudo systemctl restart haproxy
Now you can access the stats page by visiting:
http://your-haproxy-ip:8080/haproxy?stats
Fine-Tune HAProxy Configuration (Optional)
Load Balancing Algorithms: HAProxy supports multiple load-balancing algorithms. You can change roundrobin to leastconn, source, or uri to alter how HAProxy distributes traffic.
SSL Termination: To handle SSL traffic, configure HAProxy to handle HTTPS (port 443) and terminate SSL connections.
Health Checks: HAProxy automatically checks the health of the backend servers. The option httpchk directive allows you to customize this by sending HTTP requests to verify the health of each backend.
Documentation is below on fine tuning your haproxy configuration.
Troubleshooting and Logs
If HAProxy isn’t working as expected, check the logs:
sudo tail -f /var/log/haproxy.log
Make sure your backend servers are running and accessible from the HAProxy server.
Documentation
Refer to the official documentation on further usage of HAProxy and configuration options:
Disclaimer: HAProxy® is a registered trademark of HAProxy Technologies LLC. HAProxy Community Edition is released under the GNU General Public License version 2 (GPLv2). The license comes with a “no warranty” clause, meaning the software is provided “as-is” without any guarantees or liability for issues that may arise.
Cloud Solution Architect. Helping customers transform their business to the cloud. 20 years experience working in complex infrastructure environments and a Microsoft Certified Solutions Expert on everything Cloud.