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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
| global #全局配置
maxconn 100000 #最大连接数
chroot /usr/local/haproxy
uid 99
gid 99
daemon #以后台形式运行haproxy
nbproc 1 #启动1个haproxy实例
pidfile /usr/local/haproxy/logs/haproxy.pid #pid存放路径
log 127.0.0.1 local3 info #日志输出
#后端设置
defaults #默认配置
option http-keep-alive
maxconn 100000
mode http #所处理的级别.默认采用http模式
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
#开启haproxy Status状态监控,增加验证
listen stats
mode http
bind 0.0.0.0:8888
stats enable
stats uri /haproxy-status #监控页面url
stats auth haproxy:saltstack #监控页面user:passwd
#前端设置
frontend frontend_www_example_com
bind 192.168.1.100:80
mode http
option httplog
log global
default_backend backend_www_example_com
#后端设置
defaults #默认配置
option http-keep-alive
maxconn 100000
mode http #所处理的级别.默认采用http模式
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
#开启haproxy Status状态监控,增加验证
listen stats
mode http
bind 0.0.0.0:8888
stats enable
stats uri /haproxy-status #监控页面url
stats auth haproxy:saltstack #监控页面user:passwd
#前端设置
frontend frontend_www_example_com
bind 192.168.1.100:80
mode http
option httplog
log global
default_backend backend_www_example_com
#后端设置
backend backend_www_example_com
option forwardfor header X-REAL-IP #获得客户端真实ip
option httpchk HEAD / HTTP/1.0
balance roundrobin #轮训算法
server web-node1 192.168.1.12:8080 check inter 2000 rise 30 fall 15
server web-node2 192.168.1.13:8080 check inter 2000 rise 30 fall 15
|