Install Homebrew

Open your terminal and then run command bellow to install homebrew.

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Visit Homebrew official Website for more details.

Install haproxy Using Homebrew

brew install haproxy

Add Configuration

Update haproxy configution file located in /usr/local/etc/haproxy.cfg.
Create if dosen’t exists already.

Here is an initial configuration for you 🙂

global
    log  127.0.0.1   local0
    log  127.0.0.1   local1 debug
    maxconn 4096
    user rimonmostafiz
    group admin
    daemon
    pidfile /var/run/haproxy.pid
defaults
    log global
    mode        http
    option      httplog
    option      dontlognull
    option      forwardfor
    option      http-server-close
    retries 3
    option redispatch
    timeout connect  50000
    timeout client  50000
    timeout server  50000

listen stats
    bind		127.0.0.1:8900
    mode     	http
    log 		global

    maxconn 10

    timeout queue	100s

    stats enable
    stats hide-version
    stats refresh 30s
    stats show-node
    stats auth admin:password
    stats uri /haproxy?stats

Note: you need to update user and group with your username and group name of global section.

Start haproxy

sudo haproxy -f /usr/local/etc/haproxy.cfg

Check Statistics Report

Now you can check the statistic report by accesssing http://127.0.0.1:8900 with browser using username: admin and pssword: password.

Haproxy Statistics Report

Stop haproxy

ps aux | grep haproxy
kill -9 <pid>