Install HAProxy on Ubuntu 22.04 with sudo apt update followed by sudo apt install haproxy. The Jammy package provides the community HAProxy load-balancing reverse proxy. After installation, edit /etc/haproxy/haproxy.cfg, validate the configuration, restart the service, and enable it at boot. The example below publishes an HTTP listener on port 80 and distributes requests between two backend web servers.
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
What you are installing
Ubuntu 22.04 (Jammy) distributes HAProxy as the haproxy package. It is a reverse proxy and load balancer: clients connect to HAProxy, and HAProxy forwards those requests to one of the backend servers you define. The package is managed by systemd, with the service configured to start from /etc/haproxy/haproxy.cfg. Its unit is ordered after network-online.target and installed in multi-user.target, so it can start automatically during a normal multi-user boot.
As an Amazon Associate I earn from qualifying purchases.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →The package index observed for Ubuntu 22.04 listed version 2.4.30-0ubuntu0.22.04.2. That is a package version identifier from the Ubuntu security archive at the time of observation, not a permanent version promise; later security updates can change it.
Before you begin
- Use an Ubuntu 22.04 (Jammy) host with administrative access through
sudo. - Know the IP address and listening port of every backend server. The sample uses
10.0.0.11:80and10.0.0.12:80; replace them with addresses reachable from the HAProxy host. - Choose a frontend port that is not already occupied. The example binds TCP port 80 on every local interface.
- Permit traffic in both directions: clients must be able to reach the frontend port, and the HAProxy host must be able to reach each backend port.
- Have a maintenance window if another service already uses the configuration file or port you need.
Check the operating-system release before changing packages:
#1 Best Overall
- Professional 10Gbps Wired Routing – Route10 is a high-performance 10 Gigabit wired router designed for advanced home, business, and enterprise networks; it does not broadcast Wi-Fi, and wireless coverage requires pairing with one or multiple Wi-Fi access points such as ceiling, wall, or outdoor access points for full network coverage.
- Quad-Core Qualcomm Network Accelerator for High Throughput – Powered by a high-performance quad-core Qualcomm processor with hardware-accelerated networking, the Route10 delivers fast packet processing, low latency, and consistent multi-gigabit performance for routing, firewall rules, VPN traffic, VLAN segmentation, and high-bandwidth network workloads without bottlenecks.
- Integrated PoE+ Output to Power Network Devices – Select Ethernet ports provide Power over Ethernet Plus (PoE+) support, allowing the router to power compatible access points, network devices, or edge hardware directly through the Ethernet cable, reducing the need for additional power adapters or injectors.
- Enterprise-Grade Routing, Firewall, and Network Control – Supports advanced routing features including VLAN tagging, QoS traffic prioritization, NAT port forwarding, firewall rules, DHCP services, and professional network segmentation for secure, reliable, and scalable wired network deployments.
- Real-Time Network Monitoring and Traffic Visibility – Provides live network statistics and real-time monitoring of bandwidth usage, connected devices, WAN and LAN traffic, and system performance, allowing network administrators to quickly identify issues, optimize traffic flow, and maintain stable, high-performance wired networks.
. /etc/os-release && echo "$PRETTY_NAME"
The output should identify Ubuntu 22.04. If the host is another Ubuntu release, use instructions and package availability for that release instead of assuming Jammy behavior.
Install HAProxy from Ubuntu’s Jammy repository
- Refresh package metadata.
sudo apt updateThis downloads current package indexes, including security updates available to the configured Ubuntu 22.04 repositories.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. - Install the community package.
sudo apt install haproxyAccept the proposed dependency changes when prompted. Ubuntu describes this package as a load-balancing reverse proxy.
- Confirm the installed binary.
haproxy -vThe displayed version depends on the Jammy package revision currently available to your configured repositories. Do not treat the observed
2.4.30-0ubuntu0.22.04.2value as a requirement for every installation.
Understand the service and configuration paths
The main configuration file is /etc/haproxy/haproxy.cfg. The Ubuntu systemd unit starts HAProxy with that path, so edits elsewhere do not affect the packaged service unless you create a separate service definition.
Make a rollback copy before editing:
sudo cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.bak
Keep the backup outside any automated overwrite process and update it after you have a known-good configuration. HAProxy will not safely apply a malformed file; validate the file before every restart.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchBuild a minimal HTTP reverse proxy and load balancer
Open the packaged configuration with a root-capable editor:
Rank #2
- Compatible management via CloudKey, Official UniFi Hosting, or UniFi Network Server running version 8.3.32 or newer
- Ensures continuous connection through Shadow Mode High Availability featuring automatic failover (VRRP)
- Delivers 12.5 Gbps routing performance equipped with IDS/IPS capabilities
- Offers license-free, real-time decryption and inspection of encrypted traffic using NeXT AI Inspection*
- Features 25G SFP28, 10G SFP+, and 2.5 GbE RJ45 ports where two interfaces can be reconfigured as WAN connections
sudo editor /etc/haproxy/haproxy.cfg
For a minimal HTTP setup, define one frontend and one backend:
frontend http
bind *:80
mode http
default_backend web-backend
backend web-backend
balance roundrobin
server web1 10.0.0.11:80 check
server web2 10.0.0.12:80 check
How the frontend works
frontend httpnames the client-facing section. The name is an internal label and can be changed.bind *:80listens on port 80 on all local IPv4 interfaces. Replace*with a specific local address when you intentionally want to limit exposure.mode httptells HAProxy to process the listener as HTTP rather than as an opaque TCP stream.default_backend web-backendsends requests that do not match a more specific routing rule to the backend section with that name.
How the backend works
backend web-backenddefines the pool of destination servers.balance roundrobinselects servers in turn, distributing successive requests across the available members.- Each
serverline has an HAProxy name, an address and port, and thecheckoption. The namesweb1andweb2are labels used in status output; they do not need to match DNS names.
Use the exact addresses and ports your applications expose. A private address such as 10.0.0.11 is only an example. HAProxy must be able to route to it from the proxy host, and the backend firewall must permit that connection.
Use health checks so failed servers leave rotation
Appending check to a server line enables an active health check. HAProxy’s basic TCP-layer check attempts to connect to the server (or send an HTTP request at a regular interval, depending on the check configuration). A server that answers the connection handshake is considered available; a failed server is removed from load-balancing rotation until it recovers. This prevents new requests from being sent to a machine that is unreachable.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
A TCP check confirms reachability of the configured port, not that your application has returned a correct page. If an application needs a deeper test, you must define an HTTP health-check path and expected behavior appropriate to that application; do not assume that a successful TCP handshake proves application health.
Validate the file before applying it
Run HAProxy’s configuration check as root so it can read every referenced file:
sudo haproxy -c -f /etc/haproxy/haproxy.cfg
A successful check reports that the configuration file is valid. If HAProxy reports a line number, correct that line and run the command again. Typical causes include a misspelled keyword, an invalid address or port, an unclosed section edit, or a directive placed in the wrong section. Do not restart while the check is failing.
Start, enable and inspect the service
- Restart HAProxy after a successful validation.
sudo systemctl restart haproxy - Inspect the unit and its recent result.
sudo systemctl status haproxyLook for an
active (running)state. If the service failed, the status output normally includes the immediate reason.Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.Rank #3
Titan Networx - Hardwired Router TNGR-4000- Hardwired Router
- Titan Networx
- High performance router
- managed switch
- integrated router
- Enable startup at boot.
sudo systemctl enable haproxyThe packaged unit is installed for
multi-user.target, so enabling it makes HAProxy start during subsequent normal boots.
Enabling a service and starting it are separate operations. restart applies the configuration now; enable records the boot-time relationship. Use both when this host should provide the proxy after a reboot.
Open the network paths HAProxy needs
Port 80 must be reachable from clients, and the backend addresses and ports must be reachable from the HAProxy host. If Ubuntu’s uncomplicated firewall (UFW) is enabled, allow the frontend port according to your site’s policy:
sudo ufw allow 80/tcp
That command changes the host firewall; it does not configure upstream cloud security groups, network ACLs, hardware firewalls, or the backend servers’ own firewalls. Permit only the source ranges and ports required by your deployment. If another local process already owns port 80, HAProxy cannot bind to it; stop or reconfigure that process, or select a different frontend port.
Free tools Windows power users keep installed
One-click scans. No signup required.
Test the listener and the backend path
From the HAProxy host, first test the local listener:
curl -I http://127.0.0.1/
From a client that should use the service, send a request to the HAProxy host’s address rather than directly to a backend. A response demonstrates that the listener accepted the connection and selected an available backend. If your backend application does not implement HEAD, use a normal request instead:
curl -v http://PROXY_ADDRESS/
Replace PROXY_ADDRESS with the proxy’s reachable address; it is a placeholder for a real hostname or IP and should not be copied literally.
When no backend is available, HAProxy can accept the frontend connection but has nowhere to forward it. Check each backend directly from the proxy host using its real address and port, then inspect the service status and firewall rules on that backend.
Troubleshoot the common installation failures
| Symptom | What to check | Corrective action |
|---|---|---|
apt install haproxy cannot find the package |
Release identification and package indexes | Confirm the machine is Ubuntu 22.04 and run sudo apt update. Check that the configured Jammy repositories are reachable and enabled. |
| Validation reports a syntax or parsing error | The line named in haproxy -c output |
Fix the directive, section placement, address, or port, then rerun sudo haproxy -c -f /etc/haproxy/haproxy.cfg. Restart only after it succeeds. |
| Service fails with an address-in-use or bind error | Another process listening on the frontend port | Identify the process with a socket-listening tool such as sudo ss -ltnp | grep ':80'. Reconfigure that process, stop it if appropriate, or change the HAProxy bind port. |
| Service is running but every backend is unavailable | Backend IP, port, route, and firewall; whether the application is listening | Test the real backend endpoint from the HAProxy host. Correct the server line or permit the backend connection. A failed check server is intentionally removed from rotation. |
| Clients time out while local tests work | UFW, cloud security groups, upstream firewalls, and the address used in bind |
Permit the client-to-proxy port on every network layer and ensure the client is using an address on which HAProxy is listening. |
| HAProxy exits immediately after a change | Service status and the system journal | Run sudo systemctl status haproxy and review sudo journalctl -u haproxy. Restore the backup if necessary, validate it, and restart. |
Modify the example safely
Adding or removing backend servers
Add another server line inside web-backend when a new server is reachable and serves the same traffic:
server web3 10.0.0.13:80 check
Remove a server line only after traffic has been drained or redirected according to your application’s needs. Every edit follows the same sequence: save the file, validate it, restart HAProxy, and inspect the service.
Changing the frontend port
Change bind *:80 to another free port when port 80 is reserved by another service. Update firewall rules and client URLs at the same time. The backend port does not have to equal the frontend port; they are independent endpoints.
Choosing a specific bind address
Binding to * exposes the listener on every matching local interface. A specific address limits the listener to that interface, which is useful when the host has separate public and private networks. The chosen address must exist on the host when HAProxy starts.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsCommunity package versus HAProxy Enterprise
These installation steps describe Ubuntu’s free community package. HAProxy Enterprise uses a separate licensed Ubuntu 22.04 repository path and requires an enterprise key, so its repository setup and entitlement process are different.
| Area | Ubuntu community package | HAProxy Enterprise |
|---|---|---|
| Installation source | Ubuntu’s Jammy package repositories; install with sudo apt install haproxy. |
Separate licensed Ubuntu 22.04 repository setup. |
| License and entitlement | Normal Ubuntu community-package flow; no enterprise key is required for this procedure. | Requires a provided enterprise license key. |
| Updates | Ubuntu package revisions and security updates, which can change the installed version. | Enterprise repository and release channel. |
| Support and modules | Community distribution and its packaged feature set. | Enterprise support entitlement and enterprise modules, subject to the purchased edition. |
| Compatibility consideration | Designed for the standard Jammy package workflow described here. | Verify the licensed repository and edition support for Ubuntu 22.04 before deployment. |
For a normal Ubuntu 22.04 installation, the community package is the straightforward default. Do not add enterprise repository instructions or keys unless you have that separate entitlement.
Updating or removing the package
When Ubuntu publishes a newer Jammy revision, refresh metadata and apply normal package updates according to your maintenance policy. Before an update, keep a copy of the working configuration and plan a validation and service check afterward:
sudo apt update
sudo apt install --only-upgrade haproxy
sudo haproxy -c -f /etc/haproxy/haproxy.cfg
sudo systemctl restart haproxy
sudo systemctl status haproxy
If you no longer need HAProxy, remove the package through APT. Removing software does not automatically redesign firewall rules, DNS, client configuration, or backend services; clean those dependencies separately and deliberately.
Quick Recap
sudo apt remove haproxy
Installation checklist
- The host identifies as Ubuntu 22.04 (Jammy).
sudo apt updatecompleted without repository errors.sudo apt install haproxycompleted andhaproxy -vreports an installed binary./etc/haproxy/haproxy.cfgcontains a frontend, a default backend, a balancing method, and reachable server lines.- Each backend has
checkwhen active TCP health checks are appropriate. sudo haproxy -c -f /etc/haproxy/haproxy.cfgsucceeds before restart.sudo systemctl restart haproxyleaves the unit active.sudo systemctl enable haproxyis set if the proxy must return after reboot.- Client-to-frontend and proxy-to-backend firewall paths are permitted.
- A request to the proxy address reaches an available backend.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




