haproxy配置文件

#########################################################################
# HAProxy 配置文件
#########################################################################
 
global
# 使用系統的syslog記錄日誌(經過udp,默認端口號爲514)
log 127.0.0.1 local0 # info [err warning info debug]
chroot /home/user/haproxy
 
#限制單個進程的最大鏈接數
maxconn 65535
 
# 讓進程在後臺運行,即做爲守護進程運行,正式運行的時候開啓,此處先禁止,等同於在命令行添加參數 -D
# daemon
# 指定做爲守護進程運行的時候,要建立多少個進程,默認只建立一個,須要daemon開啓模式
# nbproc 1
 
# 設置debug模式運行,與daemon模式只能互斥,等同於在命令行添加參數 -d
# debug
pidfile /home/user/haproxy/logs/haproxy.pid    # not work
 
defaults
# 在鏈接失敗或斷開的狀況下,容許當前會話被從新分發
option redispatch
# 設置在一個服務器上連接失敗後的重連次數
retries 2
# 設置服務器分配算法
balance roundrobin
 
# 不記錄空鏈接
option dontlognull
 
# 設置等待鏈接到服務器成功的最大時間
timeout connect 5000ms
# 設置客戶端的最大超時時間
timeout client 1800000ms
# 設置服務器端的最大超時時間
timeout server 1800000ms
 
# Enable the sending of TCP keepalive packets on both sides, clients and servers
# NOTE: 在服務器CPU強勁的狀況下,最好不要開啓保活,這樣可減小資源消耗
#option tcpka
 
##############################統計頁面配置##################################
 
listen admin_stat
# 監聽端口
bind *:8011
# http的7層模式
mode http
option httplog
log global
# 統計頁面自動刷新時間
stats refresh 30s
# 統計頁面URL
stats uri /admin?stats
# 統計頁面密碼框上提示文本
stats realm Haproxy\ Statistics
# 統計頁面用戶名和密碼設置
stats auth admin:admin
# 隱藏統計頁面上HAProxy的版本信息
stats hide-version
 
###########################TCP鏈接的監聽配置################################
 
listen  tcp-in
bind *:2211
mode tcp
# 日誌記錄選項
option tcplog
log global
 
# 後臺服務器
# weight  -- 調節服務器的負重
# check -- 容許對該服務器進行健康檢查
# inter  -- 設置連續的兩次健康檢查之間的時間,單位爲毫秒(ms),默認值 2000(ms)
# rise  -- 指定多少次連續成功的健康檢查後,便可認定該服務器處於可操做狀態,默認值 2
# fall  -- 指定多少次不成功的健康檢查後,認爲服務器爲當掉狀態,默認值 3
# maxconn  -- 指定可被髮送到該服務器的最大併發鏈接數
server localhost 0.0.0.0:2233 weight 3 check inter 2000 rise 2 fall 3
server 192.168.1.100 192.168.1.100:2233 weight 3 check inter 2000 rise 2 fall 3
server 192.168.1.101 192.168.1.101:2233 weight 3 check inter 2000 rise 2 fall 3
 
#########################HTTP鏈接的監聽配置################################
 
listen  http-in
bind *:2212
mode http
option httplog
log global
 
# 設置健康檢查模式
#option httpchk OPTIONS * HTTP/1.1\r\nHost:\ www
#option smtpchk
 
# 後臺服務器
server localhost 0.0.0.0:2234 weight 3 check inter 2000 rise 2 fall 3
server 192.168.1.100 192.168.1.100:2234 weight 3 check inter 2000 rise 2 fall 3
server 192.168.1.101 192.168.1.101:2234 weight 3 check inter 2000 rise 2 fall 3
相關文章
相關標籤/搜索