Web Servers

Host HAProxy on VeloxaHost

HAProxy is a TCP and HTTP load balancer and reverse proxy known for speed, detailed health checks and fine-grained routing rules. Operators self-host it in front of web apps and APIs to spread traffic over several backends, terminate TLS and keep serving when one backend fails.

The one-click install puts Ubuntu 24.04's haproxy package on the server, which is the 2.8 long-term support branch, and starts the haproxy systemd service. The configuration is /etc/haproxy/haproxy.cfg; as installed it has global settings and defaults but no frontends, so HAProxy listens on nothing until you add one.

Where HAProxy fits on VeloxaHost

Many apps behind one port. Every server gets a block of ports (10 by default) on the region's shared IPv4 address, and the first forwards to SSH. If one server runs several web apps, HAProxy can take a single forwarded port and route by host name, so each app does not need a port of its own:

frontend web
    bind :8080
    use_backend wiki if { hdr(host) -i wiki.example.com:20001 }
    default_backend app

backend app
    server a1 127.0.0.1:3000 check

backend wiki
    server w1 127.0.0.1:8081 check

TLS termination. With a dedicated IPv4 address (a paid add-on with limited availability), HAProxy can listen on 443 with bind :443 ssl crt /etc/haproxy/certs/, using certificates from Certbot or acme.sh. Shared IPv4 cannot offer ports 80 and 443, and IPv6 is not available in US East yet.

Load balancing across servers. VeloxaHost's managed load balancers, private networks and floating IPs are not available in US East yet. HAProxy is the do-it-yourself option, with one caveat: servers cannot reach each other over the host's bridge, so each backend has to be reached through its own forwarded shared IPv4 port. Traffic between HAProxy and backends then crosses the public network; encrypt it with ssl verify required on the server lines, and attach VeloxaHost firewalls to the backends.

Sizing

HAProxy is event-driven and very light: a small proxy uses a few tens of megabytes. CPU matters when it terminates TLS for many new connections. 512 MB and one vCPU suit most small sites.

Install it yourself

  1. On Ubuntu 24.04, install the package.
    apt install -y haproxy
    
  2. Add your frontend and backend sections to /etc/haproxy/haproxy.cfg.
  3. Check the configuration before applying it.
    haproxy -c -f /etc/haproxy/haproxy.cfg
    
  4. Reload without dropping connections.
    systemctl reload haproxy
    
  5. Forward a port from your block to the bind port, or use a dedicated IPv4 address for 80 and 443.

FAQ

How do I see backend health?

Add a stats page to a frontend: stats enable, stats uri /haproxy-stats and stats auth admin:a-long-password. It shows each server's state, health check results and traffic. Keep it on a port only you can reach.

How long is HAProxy 2.8 supported?

2.8 is an LTS branch, maintained for about five years from its 2023 release. Ubuntu ships security fixes for it through apt upgrade. Newer branches come from the haproxy.debian.net repositories listed on haproxy.org.

How do I back up the configuration?

It is one file, /etc/haproxy/haproxy.cfg, plus any certificates in /etc/haproxy/certs. Keep it in Git, and schedule VeloxaHost snapshots (hourly to weekly, kept 1 to 30 days).

HAProxy or Caddy?

Caddy gets certificates on its own and needs less configuration for a few sites. HAProxy has richer health checks, TCP proxying and load-balancing algorithms, and suits traffic you need to control closely.

What license is HAProxy under?

The GNU GPL version 2, with some header files under the LGPL.

Which VeloxaHost size fits HAProxy?

A Veloxa Nano covers the recommended size: 1 vCPU, 1 GB RAM and 25 GB of disk for $4 a month, billed at $0.01 an hour and capped at the monthly price.