HAProxy
Overview
HAProxy is the world's fastest and most widely used open-source software load balancer and reverse proxy. It powers high-traffic sites with TCP and HTTP load balancing, health checking and observability.
This image installs HAProxy 3.0 LTS and runs it as the packaged haproxy.service, with the public frontend on port 80. A self-contained demo backend makes the load balancer and the built-in Statistics Report live the moment the VM boots. A unique stats password is generated on the first boot of every VM.
What you get:
- HAProxy 3.0 LTS bound to
:80as the public frontend (HAProxy is the listener, with no nginx) - The built-in HAProxy Statistics Report at
/stats, protected by HTTP Basic auth with a per-VM password - An unauthenticated
/healthendpoint returning200 okfor load balancers and probes - A self-contained demo backend (
be_demo) of two loopback responders, so the load balancer and stats show live traffic with no external dependency - A per-VM stats password generated on first boot and recorded in a root-only file
haproxy.serviceas a systemd unit, enabled and active- 24/7 SecureAnyCloud support
Prerequisites
You need an active Azure subscription, an SSH key pair, and a VNet with a subnet in the target region. Standard_B2s (2 vCPU / 4 GiB RAM) is a good starting size.
In the network security group (NSG), allow inbound 22/tcp from your management network and 80/tcp.
Step 1 - Deploy from the Azure Marketplace
Sign in to the Azure Portal, choose Create a resource, search the Marketplace for HAProxy by SecureAnyCloud, and select Create.
On the Basics tab, pick your subscription, resource group, region and size. Under Administrator account, choose SSH public key and paste your key. Under Inbound port rules, allow SSH (22) and HTTP (80).
Select Review + create, then Create.
Step 2 - Deploy from the Azure CLI
Accept the Marketplace terms, create the VM and open port 80:
# Accept the Marketplace terms once per subscription (required before the first CLI deploy)
az vm image terms accept --urn sac1647283583153:haproxy-ubuntu-24-04:default:latest
az vm create \
--resource-group <your-rg> \
--name haproxy \
--image sac1647283583153:haproxy-ubuntu-24-04:default:latest \
--size Standard_B2s \
--admin-username azureuser \
--ssh-key-values ~/.ssh/id_ed25519.pub \
--vnet-name <your-vnet> --subnet <your-subnet> \
--public-ip-sku Standard
az vm open-port --resource-group <your-rg> --name haproxy --port 80 --priority 1010Step 3 - Connect to your VM
Connect over SSH as azureuser:
ssh azureuser@<vm-public-ip>Step 4 - Confirm HAProxy is running
Check the service state:
systemctl is-active haproxy.serviceThe command reports active. On first boot, HAProxy generates its unique stats password and starts serving the frontend on port 80.
Step 5 - Retrieve your stats password
The Statistics Report password is generated uniquely on the first boot of your VM and written to a root-only file. Read it with:
sudo cat /root/haproxy-credentials.txtThe file contains HAPROXY_STATS_URL, HAPROXY_STATS_USER (admin) and the stats password line haproxy.stats.pass. Store the password somewhere safe.
Step 6 - Open the Statistics Report
Browse to http://<vm-public-ip>/stats and sign in as admin with the password from Step 5.
The HAProxy Statistics Report shows every frontend, backend and server, with live session counters, byte counts and health-check state. Because stats admin is enabled, it also provides controls to enable or disable individual backend servers.
Step 7 - Confirm the health endpoint
HAProxy serves an unauthenticated health endpoint for load balancers and probes. Request it:
curl -s http://localhost/healthThe endpoint returns ok.
Step 8 - Verify the Statistics Report from the command line
The stats page rejects an anonymous request, rejects a wrong password and accepts the per-VM admin password:
curl -s -o /dev/null -w 'unauth=%{http_code}\n' http://localhost/stats
curl -s -o /dev/null -w 'admin=%{http_code}\n' -u "admin:<HAPROXY_STATS_PASSWORD>" http://localhost/statsThe first command returns unauth=401. The second returns admin=200.
Step 9 - See the demo backend load-balancing
Out of the box, the default frontend routes to the demo backend (be_demo). It round-robins between two loopback responders, so the Statistics Report has live traffic to show. Request the root path a few times:
curl -s http://localhost/ | grep -o 'Served by demo[12]'The output alternates between Served by demo1 and Served by demo2 as HAProxy load-balances.
Step 10 - Route to your own app servers
Edit /etc/haproxy/haproxy.cfg and repoint the be_demo backend (or add new backend sections) at your real application servers:
backend be_demo balance roundrobin option httpchk GET / http-check expect status 200 server app1 10.0.0.11:8080 check server app2 10.0.0.12:8080 checkValidate the configuration and reload HAProxy with zero downtime:
sudo haproxy -c -f /etc/haproxy/haproxy.cfgsudo systemctl reload haproxyThe reload performs a seamless, connection-preserving config swap. Your new backends then appear in the Statistics Report with live health-check state.
Maintenance
- Backends. Edit
/etc/haproxy/haproxy.cfg, validate withhaproxy -c -f /etc/haproxy/haproxy.cfg, then runsudo systemctl reload haproxy(zero downtime). - Stats password. Rotate it by editing the
stats auth admin:line in/etc/haproxy/haproxy.cfgand reloading. - Logs. HAProxy logs to the journal. Read them with
journalctl -u haproxy. - Runtime API. The admin stats socket lives at
/run/haproxy/admin.sock, for live server enable and disable throughsocat. - Upgrades. Install a newer HAProxy package from the maintainer PPA and restart the service.
- Security patches. unattended-upgrades remains enabled, so the OS continues to receive security updates automatically.
Support
SecureAnyCloud provides 24/7 expert support for this image. Contact sales@secureanycloud.com.
Deploy on Azure
Launch HAProxy on Ubuntu 24.04 LTS on Azure with 24/7 support from SecureAnyCloud.
View this image
Need Help?
Our support team is available 24/7.
sales@secureanycloud.com
Overview
HAProxy is the world's fastest and most widely used open-source software load balancer and reverse proxy. It powers high-traffic sites with TCP and HTTP load balancing, health checking and observability.
This image installs HAProxy as the packaged haproxy.service, with the public frontend on port 80. A self-contained demo backend makes the load balancer and the built-in Statistics Report live the moment the instance boots. A unique stats password is generated on the first boot of every instance. The HAProxy configuration lives on a dedicated data volume mounted at /etc/haproxy.
What you get:
- HAProxy bound to
:80as the public frontend (HAProxy is the listener, with no nginx) - The built-in HAProxy Statistics Report at
/stats, protected by HTTP Basic auth with a per-instance password - An unauthenticated
/healthendpoint returning200 okfor load balancers and probes - A self-contained demo backend of two loopback responders, so the load balancer and stats show live traffic with no external dependency
- A per-instance stats password generated on first boot and recorded in a root-only file
haproxy.serviceas a systemd unit, enabled and active- The HAProxy configuration on a dedicated, independently resizable data volume at
/etc/haproxy - 24/7 SecureAnyCloud support
Prerequisites
You need an Amazon Web Services account where you can launch EC2 instances, an EC2 key pair in the target Region, and a VPC with a subnet. m5.large is a good starting size.
In the security group, allow inbound 22/tcp from your management network and 80/tcp.
Launch the Instance from the AWS Marketplace
Sign in to the AWS Management Console, open the EC2 service, and select Launch instance. Under Application and OS Images, choose AWS Marketplace AMIs and search for HAProxy by SecureAnyCloud.
Select the SecureAnyCloud listing, choose Select, then choose Continue on the subscription summary. Pick your instance type and EC2 key pair. Under Network settings, select a security group that allows inbound ports 22 and 80 as described above.
Select Launch instance.
Launch the Instance from the AWS CLI
Launch the instance from the AMI:
aws ec2 run-instances \
--image-id <ami-id> \
--instance-type m5.large \
--key-name <key-name> \
--subnet-id <subnet-id> \
--security-group-ids <security-group-id> \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=haproxy-01}]'Connect to your Instance
The SSH login user depends on the operating system of the AMI variant you launched:
- HAProxy on Rocky Linux 9: SSH login user rocky
ssh -i <path-to-key>.pem rocky@<instance-public-ip>Confirm HAProxy is running
Check the service state:
systemctl is-active haproxy.serviceThe command reports active. On first boot, HAProxy generates its unique stats password and starts serving the frontend on port 80.
Retrieve your stats password
The Statistics Report password is generated uniquely on the first boot of your instance and written to a root-only file. Read it with:
sudo cat /root/haproxy-credentials.txtThe file contains HAPROXY_STATS_URL, HAPROXY_STATS_USER (admin) and the stats password line haproxy.stats.pass. Store the password somewhere safe.
Open the Statistics Report
Browse to http://<instance-public-ip>/stats and sign in as admin with the password from Step 5.
The HAProxy Statistics Report shows every frontend, backend and server, with live session counters, byte counts and health-check state. Because stats admin is enabled, it also provides controls to enable or disable individual backend servers.
Confirm the health endpoint
HAProxy serves an unauthenticated health endpoint for load balancers and probes. Request it:
curl -s http://localhost/healthThe endpoint returns ok.
Verify the Statistics Report from the command line
The stats page rejects an anonymous request, rejects a wrong password and accepts the per-instance admin password:
curl -s -o /dev/null -w 'unauth=%{http_code}\n' http://localhost/stats
curl -s -o /dev/null -w 'admin=%{http_code}\n' -u "admin:<HAPROXY_STATS_PASSWORD>" http://localhost/statsThe first command returns unauth=401. The second returns admin=200.
See the demo backend load-balancing
Out of the box, the default frontend routes to the bundled demo backend. It round-robins between two loopback responders, so the Statistics Report has live traffic to show. Request the root path a few times:
curl -s http://localhost/Repeated requests alternate between the two demo responders as HAProxy load-balances, and the traffic appears in the Statistics Report.
Route to your own app servers
Edit /etc/haproxy/haproxy.cfg and repoint the demo backend servers (or add new backend sections) at your real application servers:
backend demo_backend balance roundrobin option httpchk GET / http-check expect status 200 server app1 10.0.0.11:8080 check server app2 10.0.0.12:8080 checkValidate the configuration and reload HAProxy with zero downtime:
sudo haproxy -c -f /etc/haproxy/haproxy.cfgsudo systemctl reload haproxyThe reload performs a seamless, connection-preserving config swap. Your new backends then appear in the Statistics Report with live health-check state.
Maintenance
- Backends. Edit
/etc/haproxy/haproxy.cfg, validate withhaproxy -c -f /etc/haproxy/haproxy.cfg, then runsudo systemctl reload haproxy(zero downtime). - Persistence. The HAProxy configuration lives on the dedicated data volume mounted at
/etc/haproxy, so it survives reboots and can be snapshotted independently. - Stats password. Rotate it by editing the
stats auth admin:line in/etc/haproxy/haproxy.cfgand reloading. - Logs. HAProxy logs to the journal. Read them with
journalctl -u haproxy. - Runtime API. The admin stats socket lives at
/run/haproxy/admin.sock, for live server enable and disable throughsocat. - Security patches. Automatic security updates remain enabled, so the OS continues to receive security patches.
Support
SecureAnyCloud provides 24/7 expert support for this image. Contact sales@secureanycloud.com.
Deploy on AWS
Launch HAProxy on AWS with 24/7 support from SecureAnyCloud.
View on Marketplace
Need Help?
Our support team is available 24/7.
sales@secureanycloud.com