-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path.haproxy.cfg
More file actions
44 lines (44 loc) · 2.49 KB
/
.haproxy.cfg
File metadata and controls
44 lines (44 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
global
log 127.0.0.1 local0 #[日志输出配置,所有日志都记录在本机,通过local0输出]
log 127.0.0.1 local1 notice #定义haproxy 日志级别[error warringinfo debug]
daemon #以后台形式运行harpoxy
nbproc 1 #设置进程数量
pidfile /home/qmxue/.haproxy.pid
ulimit-n 51200 #ulimit 的数量限制
maxconn 8192 #默认最大连接数,需考虑ulimit-n限制
#chroot /usr/local/haproxy
defaults
log global
mode tcp #默认的模式mode { tcp|http|health },tcp是4层,http是7层,health只会返回OK
retries 3 #两次连接失败就认为是服务器不可用,也可以通过后面设置
option abortonclose #当服务器负载很高的时候,自动结束掉当前队列处理比较久的链接
option redispatch
maxconn 8192 #默认的最大连接数
timeout connect 5000ms #连接超时
timeout client 30000ms #客户端超时
timeout server 30000ms #服务器超时
balance roundrobin #设置默认负载均衡方式,轮询方式
#balance source #设置默认负载均衡方式,类似于nginx的ip_hash
#balnace leastconn #设置默认负载均衡方式,最小连接数
listen admin_stats
bind *:1111 #设置Frontend和Backend的组合体,监控组的名称,按需要自定义名称
mode http #http的7层模式
option httplog #采用http日志格式
maxconn 10 #默认的最大连接数
stats refresh 30s #统计页面自动刷新时间
stats uri /haproxy #统计页面url
stats realm Haproxy #统计页面密码框上提示文本
stats auth admin:root #设置监控页面的用户和密码:admin,可以设置多个用户名
stats hide-version #隐藏统计页面上HAProxy的版本信息
stats admin if TRUE #设置手工启动/禁用,后端服务器(haproxy-1.4.9以后版本)
frontend ss-in
bind *:9230
default_backend ss-out
backend ss-out
mode tcp
balance roundrobin
option tcplog
#option allbackups
server server2_name 47.100.170.57:9230 weight 10 maxconn 8192 check inter 1500 rise 3 fall 3
server server3_name 211.75.30.99:9230 weight 10 maxconn 8192 check inter 1500 rise 3 fall 3
server server4_name 61.219.127.215:9230 weight 10 maxconn 8192 check inter 1500 rise 3 fall 3