Skip to content

HA Proxy VM

Configure HAProxy VM

  1. SSH to HAProxy VM using the VSCode > Terminal

    ssh -l ubuntu <ip-address-of-haproxy-user01-01>
    
    ssh -l ubuntu 10.x.x.123
    
  2. Install HAProxy

    sudo apt update
    sudo apt install -y haproxy
    
  3. Configure HAProxy

    Edit configurations:

    sudo vim /etc/haproxy/haproxy.cfg
    

    Replace or append:

    frontend http_front
        bind *:80
        default_backend web_servers
    
    backend web_servers
        balance roundrobin
        server web1 _your_web_server_ip:80 check
    
  4. Enable and Restart HAProxy

    sudo systemctl enable haproxy
    sudo systemctl restart haproxy
    
  5. Verify status:

    sudo systemctl status haproxy
    
    8. Firewall Rules (If Enabled)

    sudo ufw allow 80
    sudo ufw enable
    

Validation

  1. Test Load Balancing

    Open a browser to point to your HAProxy VM IP.

    http://192.168.1.10
    

    Refresh multiple times — requests should alternate between frontend servers.