LAB16: HA Proxy Load Balancer

LAB 41: HA Proxy Load balancer

Your final architecture will be:

Client → HAProxy (Public IP) → NodePorts → Ingress Controller → Services → Pods

STEP 1 — Install HAProxy on Your LB VM

sudo apt update
sudo apt install -y haproxy

Check version:

haproxy -v

STEP 2 — Create HAProxy Config for Multiple Ingress Hosts

We’ll support two domains:

  • fileshare.local → nginx ingress

Open HAProxy config:

sudo nano /etc/haproxy/haproxy.cfg

Replace with:

global
    log /dev/log local0
    maxconn 2048

defaults
    log global
    mode http
    option httplog
    timeout connect 5s
    timeout client  50s
    timeout server  50s

# FRONTEND: receives all HTTP traffic
frontend http_front
    bind *:80

    # Map by Host header
    acl host_fileshare hdr(host) -i fileshare.local

    use_backend nginx_ingress if host_fileshare


    # Default (if host doesn't match)
    default_backend nginx_ingress

# BACKEND: NGINX ingress (NodePort 32252)
backend nginx_ingress
    balance roundrobin
    mode http
    server node_master   3.239.117.77:32252 check
    server node_worker1  35.171.244.121:32252 check
    server node_worker2  44.197.102.217:32252 check

Save & exit.


STEP 3 — Restart HAProxy

Expected:



STEP 5 — Add Local DNS Entries

On your laptop/workstation:


STEP 6 — Test NGINX Ingress

Expected: HTTP/1.1 200 OK


OPTIONAL — Load Balance MySQL, Redis, Postgres, etc.

To balance MySQL port 3306:

HAProxy is both:

  • L7 Reverse Proxy (HTTP/TLS)

  • L4 Network Load Balancer (TCP)

Last updated