要啟動 HAProxy Statistics,需將 HAProxy 設定檔開啟進行設定。

sudo vim /etc/haproxy/haproxy.cfg

1.png

將設定檔加上如下設定:

# HAProxy Statistics
listen  stats
bind :9000
mode http
stats enable  # Enable stats page
stats hide-version  # Hide HAProxy version
stats realm Haproxy\ Statistics  # Title text for popup window
stats uri /haproxy_stats  # Stats URI
stats auth Username:Password  # Authentication credentials

2.png

設定檔的 bind、uri 與 auth 資訊需視需要調動。

接著調用命令啟動 HAProxy。

sudo service haproxy start

3.png

訪問設定的 HAProxy Statistics 網址。

4.png

帶入設定檔 auth 那邊設定的帳密。

就可以看到 HAProxy Statistics 的報表頁面。

5.png