搜尋此網誌

顯示具有 HAPROXY 標籤的文章。 顯示所有文章
顯示具有 HAPROXY 標籤的文章。 顯示所有文章

2017年1月31日 星期二

使用 haproxy 來分流2


依照訪問的PORT號  分配訪問候端伺服器


frontend  http
bind 47.90.90.112:5222
bind 47.90.90.112:5333


設定規則
    acl d1 dst_port 5222
    use_backend JabberD1 if d1

依照規則分流
backend JabberD1
    tcp-check connect
    tcp-check send PING\r\n
    tcp-check expect string +PONG
    server Server1ZoneD 10.60.30.209:80  check

backend JabberE1
    tcp-check connect
    tcp-check send PING\r\n
    tcp-check expect string +PONG
    server Server1ZoneE 10.60.47.4:80    check


參考 http://serverfault.com/questions/577103/how-to-configure-haproxy-to-route-by-port-without-using-multiple-frontend-or-lis/589148

使用 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



搜尋此網誌