[{"data":1,"prerenderedAt":181},["ShallowReactive",2],{"seo-verification":3,"blog-haproxy-on-a-vps-load-balancing-and-high-availability-ma-en":6,"promo-bar-likely":180},{"google":4,"bing":5},"EycwPY2XMyTkVzas3n1ygeNJFGAH513qrMjfDljzsMQ","",{"key":7,"data":8},"blog-haproxy-on-a-vps-load-balancing-and-high-availability-ma-en",{"id":9,"slug":10,"slugs":11,"title":15,"excerpt":16,"readTime":17,"views":18,"isPinned":19,"noindex":19,"publishedAt":20,"updatedAt":21,"category":22,"categories":27,"featuredImage":29,"bgImage":30,"posterImage":31,"relatedSolution":32,"intro":35,"sections":36,"ctaTitle":123,"ctaBody":124,"ctaButton":125,"ctaUrl":126,"relatedPosts":127},142,"haproxy-on-a-vps-load-balancing-and-high-availability",{"fr":12,"en":10,"ar":13,"es":14},"deployer-avec-haproxy-vps","haproxy-على-خادم-vps-موازنة-الأحمال-والتوافر-العالي","haproxy-en-un-vps-balanceo-de-carga","HAProxy on a VPS: load balancing and high availability","Install HAProxy on a VPS to distribute traffic, monitor backends and prepare a more resilient web architecture.",8,1,false,"2026-02-03T00:00:00+00:00","2026-10-13T14:10:29+00:00",{"id":23,"name":24,"slug":25,"color":26,"icon":25},3,"Deployment","deploiement","bg-success\u002F10 text-success",[28],{"id":23,"name":24,"slug":25,"color":26,"icon":25},null,"\u002Fblog\u002Fcovers\u002Fbg.svg","\u002Fblog\u002Fcovers\u002Fdeployer-avec-haproxy-vps-poster.svg",{"categorySlug":33,"appSlug":34},"infra","haproxy","HAProxy is the de facto standard for load balancing and high availability on Linux servers. On a ServOrbit VPS, it installs in minutes via the Marketplace and is fully configured from the `\u002Fetc\u002Fhaproxy\u002Fhaproxy.cfg` file. This in-depth guide covers the complete setup — frontend\u002Fbackend, ACLs, SSL\u002FTLS termination, health checks, statistics page and troubleshooting of the most common errors — so your infrastructure is ready for production.",[37,41,51,79,82,106,109,117,120],{"type":38,"title":39,"body":40},"h2","Why host HAProxy on a dedicated VPS?","HAProxy (High Availability Proxy) is an open source load balancing and TCP\u002FHTTP proxy software recognized for its production performance. Hosting it on a dedicated VPS lets you centralize traffic distribution among your application servers, ensure service continuity in case of node failure, and fine-tune routing rules without license fees. On a single 2 vCPU \u002F 2 GB RAM VPS, HAProxy effortlessly handles thousands of simultaneous connections. It is the preferred solution of technical teams who want a robust, controlled infrastructure at a managed cost.",{"type":42,"title":43,"items":44},"ul","What you can do with HAProxy",[45,46,47,48,49,50],"Distribute HTTP\u002FHTTPS traffic among several application servers with configurable algorithms (roundrobin, leastconn, source…)","Set up a reverse proxy to expose several internal services behind a single public IP address","Monitor backend health with automatic health checks and remove a failing server without service interruption","Terminate SSL\u002FTLS connections at the front end (offloading) to relieve your application servers from encryption","Route traffic by domain or path with ACLs (host_hdr, path_beg) on a single port 443","Consult real-time traffic statistics via HAProxy's built-in web interface (stats uri \u002Fstats)",{"type":52,"title":53,"steps":54},"steps","Install and configure HAProxy on your ServOrbit VPS",[55,58,61,64,67,70,73,76],{"title":56,"body":57},"Order a ServOrbit Cloud VPS and launch the installation","Go to \u002Fvps-cloud and choose a plan with at least 2 vCPU and 2 GB RAM. From your VPS dashboard, open the Marketplace, search for 'HAProxy' and click Install. ServOrbit's automatic provisioning installs HAProxy via apt and enables the service — no SSH connection required at this stage. You can also install manually: `sudo apt update && sudo apt install -y haproxy`",{"title":59,"body":60},"Understand the structure of haproxy.cfg","The main configuration file is at `\u002Fetc\u002Fhaproxy\u002Fhaproxy.cfg`. It is organized into four sections: `global` (process, logs, system limits), `defaults` (inherited timeouts and modes), `frontend` (listening ports, ACL rules) and `backend` (target servers, algorithm, health checks). Edit it with: `sudo nano \u002Fetc\u002Fhaproxy\u002Fhaproxy.cfg`",{"title":62,"body":63},"Configure a complete HTTP\u002FHTTPS frontend and backend","Here is a complete configuration for two application servers with SSL termination:\n\n```\nglobal\n    log \u002Fdev\u002Flog local0\n    maxconn 50000\n    user haproxy\n    group haproxy\n\ndefaults\n    log     global\n    mode    http\n    option  httplog\n    timeout connect 5s\n    timeout client  30s\n    timeout server  30s\n\nfrontend http_front\n    bind *:80\n    redirect scheme https code 301\n\nfrontend https_front\n    bind *:443 ssl crt \u002Fetc\u002Fhaproxy\u002Fcerts\u002Fbundle.pem\n    default_backend app_servers\n\nbackend app_servers\n    balance roundrobin\n    option httpchk GET \u002Fhealth\n    server app1 192.168.1.10:3000 check weight 1 inter 2s fall 3 rise 2\n    server app2 192.168.1.11:3000 check weight 2 inter 2s fall 3 rise 2\n```\n\nThe `weight` parameter sends proportionally more traffic to app2. The `option httpchk GET \u002Fhealth` directive sends an HTTP request to the `\u002Fhealth` endpoint of each backend to verify it responds correctly.",{"title":65,"body":66},"Configure ACLs for domain and path-based routing","ACLs allow routing traffic to different backends based on the domain name or request path. Add to your frontend:\n\n```\nfrontend https_front\n    bind *:443 ssl crt \u002Fetc\u002Fhaproxy\u002Fcerts\u002Fbundle.pem\n\n    acl host_api   hdr(host) -i api.mysite.com\n    acl host_app   hdr(host) -i app.mysite.com\n    acl path_admin path_beg  \u002Fadmin\n\n    use_backend api_servers   if host_api\n    use_backend admin_servers if path_admin\n    use_backend app_servers   if host_app\n    default_backend app_servers\n```\n\nThe `hdr(host)` directive inspects the HTTP Host header to identify the domain. `path_beg \u002Fadmin` routes all requests whose path starts with `\u002Fadmin` to a dedicated backend.",{"title":68,"body":69},"Terminate SSL\u002FTLS with Let's Encrypt and create the PEM bundle","HAProxy expects a `.pem` file containing the certificate, the intermediate chain and the private key in that order. After obtaining your certificate with Certbot, create the bundle:\n\n```\nsudo mkdir -p \u002Fetc\u002Fhaproxy\u002Fcerts\nsudo cat \u002Fetc\u002Fletsencrypt\u002Flive\u002Fmysite.com\u002Ffullchain.pem \\\n         \u002Fetc\u002Fletsencrypt\u002Flive\u002Fmysite.com\u002Fprivkey.pem \\\n  | sudo tee \u002Fetc\u002Fhaproxy\u002Fcerts\u002Fbundle.pem\nsudo chmod 600 \u002Fetc\u002Fhaproxy\u002Fcerts\u002Fbundle.pem\n```\n\nTo automate renewal, add a post-hook in `\u002Fetc\u002Fletsencrypt\u002Frenewal-hooks\u002Fpost\u002Fhaproxy.sh` that rebuilds the bundle and runs `systemctl reload haproxy`.",{"title":71,"body":72},"Enable the HAProxy statistics page","The built-in statistics page gives a real-time view of each frontend, backend and server. Add a dedicated frontend block:\n\n```\nfrontend stats\n    bind *:8404\n    stats enable\n    stats uri \u002Fstats\n    stats refresh 10s\n    stats auth admin:SecretPassword\n    stats hide-version\n```\n\nAccess it at `http:\u002F\u002Fyour-ip:8404\u002Fstats`. The `stats auth` field protects the page with HTTP Basic authentication.",{"title":74,"body":75},"Validate the configuration and reload without interruption","Before any reload, validate the configuration file syntax:\n\n```\nsudo haproxy -c -f \u002Fetc\u002Fhaproxy\u002Fhaproxy.cfg\n```\n\nIf the command displays `Configuration file is valid`, reload HAProxy without dropping active connections:\n\n```\nsudo systemctl reload haproxy\n```\n\nCheck that the service is active: `sudo systemctl status haproxy`. The `reload` command (not `restart`) guarantees a graceful reload: established connections finish normally before the old workers stop.",{"title":77,"body":78},"Check logs and monitor continuously","HAProxy sends its logs to syslog. View them in real time:\n\n```\nsudo journalctl -u haproxy -f\n```\n\nEach line shows the frontend, backend, selected server, HTTP code and connection times — essential for diagnosing a routing issue or slow backend.",{"type":38,"title":80,"body":81},"Advanced health checks: detecting failing backends","The `check` directive on each `server` line enables health checks. By default, HAProxy opens a TCP connection to verify the port responds. To go further, `option httpchk GET \u002Fhealth` sends a real HTTP request and waits for a 2xx code. The parameters `inter 2s fall 3 rise 2` mean: check every 2 seconds, remove the server after 3 consecutive failures, reintegrate it after 2 successes. This combination ensures a backend in error is excluded from the pool within 6 seconds at most. Add `option redispatch` so HAProxy retries failed requests on another pool server — essential for transparent failover.",{"type":83,"title":84,"headers":85,"rows":89},"comparison","Load balancing algorithms: which one to choose?",[86,87,88],"Algorithm","Behavior","Ideal for",[90,94,98,102],[91,92,93],"roundrobin","Distributes requests in turn between servers. Supports the weight parameter.","Backends with equivalent capacities",[95,96,97],"leastconn","Sends each new request to the server with the fewest active connections.","Long connections (WebSocket, database)",[99,100,101],"source","Hashes the client source IP for session persistence without a cookie.","Sessions that cannot be shared between backends",[103,104,105],"uri","Hashes the request URI to always route to the same backend.","Application caches where data locality matters",{"type":38,"title":107,"body":108},"Troubleshooting: common errors and solutions","Here are the five most common errors when configuring or reloading HAProxy, with their cause and steps to fix them.",{"type":42,"title":110,"items":111},"Common errors and how to resolve them",[112,113,114,115,116],"**`[ALERT] Starting frontend http_front: cannot bind socket [0.0.0.0:80]`** — Port 80 is already used by another process (nginx, apache2). Identify it with `sudo ss -tlnp | grep ':80'`, stop the competing service (`sudo systemctl stop nginx`) then reload HAProxy.","**`[WARNING] Server app_servers\u002Fapp1 is DOWN, reason: Layer4 connection problem`** — HAProxy cannot reach the backend IP address or port. Check the application server is running, its firewall allows connections from the HAProxy VPS IP, and the address in `haproxy.cfg` is correct.","**`[ALERT] parsing [\u002Fetc\u002Fhaproxy\u002Fhaproxy.cfg:42] : unknown keyword 'serveur'`** — Syntax error in the configuration file. The command `haproxy -c -f \u002Fetc\u002Fhaproxy\u002Fhaproxy.cfg` gives the exact line number. HAProxy keywords are in English: `server`, `frontend`, `backend`. Also check indentation (HAProxy only accepts spaces).","**`[ALERT] ssl library has no cert for frontend https_front`** or **certificate expired** — The bundle.pem file is missing, empty or contains an expired certificate. Rebuild the bundle from up-to-date Let's Encrypt files (`fullchain.pem` + `privkey.pem`) then reload.","**Statistics page returns HTTP 403** — The `stats auth` directive is configured but credentials are not sent, or the source IP is not in a `stats allow-from` whitelist. Check the URL (`\u002Fstats` by default), the credentials, and temporarily add `stats allow-from 0.0.0.0\u002F0` to diagnose.",{"type":118,"body":119},"tip","Tip: after each modification to `haproxy.cfg`, always run `sudo haproxy -c -f \u002Fetc\u002Fhaproxy\u002Fhaproxy.cfg` before `systemctl reload`. This syntax validation takes under a second and prevents a service interruption if the file contains an error.",{"type":118,"title":121,"body":122},"Going further","The \u003Ca href=\"https:\u002F\u002Fdocs.haproxy.org\u002F\" target=\"_blank\" rel=\"noopener noreferrer\">official HAProxy documentation\u003C\u002Fa> details all directives, advanced TCP options, QUIC\u002FHTTP3 support (HAProxy 2.6+) and high availability configuration with Keepalived for virtual IP failover between two HAProxy instances. This guide covers going live on a ServOrbit VPS; the vendor documentation remains the reference for fine-tuning.","Deploy HAProxy in minutes on a ServOrbit Cloud VPS","Launch your ServOrbit Cloud VPS right now and install HAProxy in 1 click via the Marketplace — professional infrastructure, without the complexity.","Launch my Cloud VPS","\u002Fvps-cloud",[128,144,161],{"id":129,"slug":130,"slugs":131,"title":135,"excerpt":136,"readTime":137,"views":23,"isPinned":19,"noindex":19,"publishedAt":138,"updatedAt":139,"category":140,"categories":141,"featuredImage":29,"bgImage":30,"posterImage":143,"relatedSolution":29},38,"deploy-your-applications-with-traefik-on-a-vps",{"fr":132,"en":130,"ar":133,"es":134},"deployer-avec-traefik","انشر-تطبيقاتك-باستخدام-traefik-على-خادم-vps","desplegar-con-traefik","Deploy your applications with Traefik on a VPS","Deploy Traefik as a reverse proxy on your VPS: automatic routing of Docker containers, Let's Encrypt SSL certificates and load balancing.",11,"2026-05-13T00:00:00+00:00","2026-11-08T01:13:13+00:00",{"id":23,"name":24,"slug":25,"color":26,"icon":25},[142],{"id":23,"name":24,"slug":25,"color":26,"icon":25},"\u002Fblog\u002Fcovers\u002Fdeployer-avec-traefik-poster.svg",{"id":145,"slug":146,"slugs":147,"title":151,"excerpt":152,"readTime":153,"views":154,"isPinned":19,"noindex":19,"publishedAt":155,"updatedAt":156,"category":157,"categories":158,"featuredImage":29,"bgImage":30,"posterImage":160,"relatedSolution":29},37,"deploy-your-applications-with-nginx-proxy-manager-on-a-vps",{"fr":148,"en":146,"ar":149,"es":150},"deployer-avec-nginx-proxy-manager","انشر-تطبيقاتك-باستخدام-nginx-proxy-manager-على-خادم-vps","desplegar-con-nginx-proxy-manager","Deploy your applications with Nginx Proxy Manager on a VPS","Manage domains, SSL and reverse proxy for several services on a VPS with Nginx Proxy Manager: installation, Docker networks, 502 troubleshooting and configuration.",10,7,"2026-05-14T00:00:00+00:00","2026-11-08T01:13:14+00:00",{"id":23,"name":24,"slug":25,"color":26,"icon":25},[159],{"id":23,"name":24,"slug":25,"color":26,"icon":25},"\u002Fblog\u002Fcovers\u002Fdeployer-avec-nginx-proxy-manager-poster.svg",{"id":162,"slug":163,"slugs":164,"title":168,"excerpt":169,"readTime":17,"views":170,"isPinned":19,"noindex":19,"publishedAt":171,"updatedAt":172,"category":173,"categories":174,"featuredImage":29,"bgImage":30,"posterImage":176,"relatedSolution":177},39,"deploy-your-applications-with-caddy-on-a-vps",{"fr":165,"en":163,"ar":166,"es":167},"deployer-avec-caddy","انشر-تطبيقاتك-باستخدام-caddy-على-خادم-vps","desplegar-con-caddy","Caddy as a reverse proxy on VPS: complete guide","Install and configure Caddy as a reverse proxy on your VPS: automatic Let's Encrypt HTTPS, multi-app setup, security hardening and common error troubleshooting.",4,"2026-05-12T00:00:00+00:00","2026-09-25T23:43:04+00:00",{"id":23,"name":24,"slug":25,"color":26,"icon":25},[175],{"id":23,"name":24,"slug":25,"color":26,"icon":25},"\u002Fblog\u002Fcovers\u002Fdeployer-avec-caddy-poster.svg",{"categorySlug":178,"appSlug":179},"application-deployment-devops","caddy",true,1794270407999]