Web & TLS · about 2 min · 7 steps
HAProxy load balancer
Spreads web traffic across several copies of your app running on this server, and stops sending to any that stop answering.
Runs on
- Debian / Ubuntu: supported
- RHEL / Fedora: supported
- Alpine: supported
What it changes on your server
- Installs HAProxy from your distribution.
- Replaces /etc/haproxy/haproxy.cfg with a round-robin setup; the original is kept once as haproxy.cfg.before-shellbay.
- Listens on the port you choose and forwards to 127.0.0.1 on your app ports, checking each is up.
- On SELinux systems, lets HAProxy connect to any port (haproxy_connect_any).
What Shellbay asks you
Which port should visitors connect to?
Usually 80 for a website. Nothing else may be using it, so if Nginx, Caddy or Apache already serves port 80, choose another port or stop that server first.
- Public port
- A port number from 1 to 65535. Default:
80
Example:
80Which ports do your app copies listen on?
Start several copies of your app, each on its own port on 127.0.0.1, then list those ports. HAProxy takes turns between them and skips any that stop answering.
- App ports
- Up to 20 ports, each optionally /tcp or /udp
Example:
3000, 3001, 3002
Steps
- Check the ports
- Refresh the package list
- Install HAProxy
- Write the load balancer configuration
- Allow HAProxy to reach your app ports
- Start HAProxy and enable it at boot
- Check HAProxy is listening
Shellbay checks the server before the first step, and stops at the first step that fails.
When it's done
- HAProxy listens on port ‹public port› and shares requests between ‹app ports›.
- If a firewall is on, allow port ‹public port›. Run this workflow again to change the ports.