haproxy从1.4版本开始,状态监控stats支持http-requset, 可以方便地编写acl规则,控制指定ip或地址段访问监控,语法如下:
stats http-request { allow | deny | auth [realm
] }
[ { if | unless } ]
Example:
acl nagios src 192.168.129.3
acl local_net src 192.168.0.0/16
stats http-request allow if nagios
stats http-request allow if local_net auth_ok
stats http-request deny
haproxy监控配置片段:
-
listen admin_state
-
bind 192.168.0.104:8000
-
mode http
-
option httplog
-
stats refresh 30s
-
stats uri /stats
-
# stats realm Haproxy Manager
-
acl mrtg src 192.168.0.105 ;定义运行访问服务器ip 192.168.0.105
-
#stats auth haproxy:haproxy123
-
stats http-request allow if mrtg ;只允许192.168.0.105访问haproxy的stats
-
stats http-request deny ;拒绝其他ip访问
阅读(5840) | 评论(0) | 转发(0) |