搜尋此網誌

2017年1月31日 星期二

使用 haproxy 來分流1

先安裝 haproxy
yum install -y haproxy

先備份之後編輯 haproxy.cfg
vi /etc/haproxy/haproxy.cfg

當user訪問 47.90.90.112:5000 時,導向 47.90.33.129:8080
當user訪問 47.90.90.112:5001 時,導向 123.51.165.168:18080
並且設置 47.90.90.112:8088 監控儀表板觀察

...
frontend  http
bind 47.90.90.112:5000
bind 47.90.90.112:5001

acl rule1 dst_port 5000
acl rule2 dst_port 5001

use_backend   tpe   if   rule1
use_backend   hk    if   rule2


# HAProxy 監控儀表板
listen stats :8088
    mode http
    stats enable
    stats hide-version
    stats realm Haproxy\ Statistics
    stats uri /
    # 帳號密碼
    stats auth your_username:your_password
    stats refresh 10s


backend hk
    balance     roundrobin
    cookie SERVERID insert indirect nocache
    server  hk1 47.90.33.129:8080

backend tpe
    balance     roundrobin
    cookie SERVERID insert indirect nocache
    server  tpe1 123.51.165.168:18080



沒有留言:

張貼留言

搜尋此網誌