添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
  • 通过web界面,显示当前HAProxy的运行状态
  • 并且可以通过状态页启停代理服务器组(出于安全,不建议使用)

HAProxy状态页配置项

stats enable    #基于默认的参数启用stats page
stats hide-version  #将状态页中haproxy版本隐藏
stats refresh <delay>   #设定自动刷新时间间隔,默认不自动刷新,以秒为单位
stats uri <prefix>  #自定义stats page uri,默认值:/haproxy?stats
stats realm <realm>  #账户认证时的提示信息,示例:stats realm HAProxy\Statistics
stats auth <user>:<passwd>  #认证时的账号和密码,可定义多个用户,每行指定一个用户.默认:no authentication
stats admin { if | unless } <cond>  #启用stats page中的管理功能

HAProxy添加现实状态页

  • 在主配置文件中添加并实现

1. 确保HAProxy服务正常

  • 查看HAProxy状态
    systemctl status haproxy.service
[root@C8-189 ~]# systemctl status haproxy.service 
● haproxy.service - HAProxy Load Balancer
   Loaded: loaded (/usr/lib/systemd/system/haproxy.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2021-06-26 19:02:08 CST; 4min 32s ago
  Process: 17118 ExecStartPre=/apps/haproxy/sbin/haproxy -f /apps/haproxy/conf/haproxy.cfg -c -q (code=exited, status=0/SUCCESS)
 Main PID: 17131 (haproxy)
    Tasks: 3 (limit: 11346)
   Memory: 28.3M
   CGroup: /system.slice/haproxy.service
           ├─17131 /apps/haproxy/sbin/haproxy -Ws -f /apps/haproxy/conf/haproxy.cfg -p /apps/haproxy/socket/haproxy.pid
           └─17138 /apps/haproxy/sbin/haproxy -Ws -f /apps/haproxy/conf/haproxy.cfg -p /apps/haproxy/socket/haproxy.pid
Jun 26 19:02:08 C8-189 systemd[1]: Starting HAProxy Load Balancer...
Jun 26 19:02:08 C8-189 systemd[1]: Started HAProxy Load Balancer.
Jun 26 19:02:08 C8-189 haproxy[17131]: [WARNING]  (17131) : config : proxy 'web_port' has no 'bind' directive. Please declare it as a backend if this was intended.
Jun 26 19:02:08 C8-189 haproxy[17131]: [NOTICE]   (17131) : New worker #1 (17138) forked
  • 查看当前服务器开放端口
    ss -ntlp
[root@C8-189 ~]# ss -ntlp
State        Recv-Q        Send-Q                Local Address:Port               Peer Address:Port                                                                       
LISTEN       0             128                         0.0.0.0:9999                    0.0.0.0:*           users:(("haproxy",pid=17138,fd=8))                             
LISTEN       0             128                         0.0.0.0:111                     0.0.0.0:*           users:(("rpcbind",pid=758,fd=4),("systemd",pid=1,fd=42))       
LISTEN       0             128                         0.0.0.0:22                      0.0.0.0:*           users:(("sshd",pid=828,fd=4))                                  
LISTEN       0             128                            [::]:111                        [::]:*           users:(("rpcbind",pid=758,fd=6),("systemd",pid=1,fd=44))       
LISTEN       0             128                            [::]:22                         [::]:*           users:(("sshd",pid=828,fd=6))    

2. 在主配置文件中添加状态页主机

  • 编辑haproxy.cfg并添加代码
listen stats
    mode http
    bind 0.0.0.0:9999
    stats enable
    log global
    stats uri /haproxy-status
    stats auth haadmin:123456

listen stats

listen <name>

  • 定义反向代理中的一个主机组
  • 类似于apahche活着nginx中的一个虚拟主机
  • 将frontend和backend合并在一起配置,
  • 相对于frontend和backend配置更简洁,生产常用

mode http

mode http|tcp

  • 指定当前反向代理主机组使用的负载协议类型
  • http 代表七层http协议转发
  • tcp 代表四层tcp协议转发
  • HAProxy 目前不能直接支持UDP和HTTPS协议转发

bind 0.0.0.0:9999

bind [<address>]:<port_range> [, ...] [param*]

  • 监听在本机所有IP的9999端口上

stats enable

  • 启用stats page

log global

  • 日志记录在全局日志中

stats uri /haproxy-status

stats uri <prefix>

  • 自定义访问路径
  • 默认为/haproxy?stats

stats auth haadmin:123456

stats auth <user>:<passwd>

  • 访问状态页时使用的用户名和密码
  • 默认no authentication 不安全

3. 访问状态页

  • 使用自定义端口和路径访问状态页
HAProxy状态页功能通过web界面,显示当前HAProxy的运行状态并且可以通过状态页启停代理服务器组(出于安全,不建议使用)HAProxy状态页配置项stats enable #基于默认的参数启用stats pagestats hide-version #将状态页中haproxy版本隐藏stats refresh &lt;delay&gt; #设定自动刷新时间间隔,默认不自动刷新,以秒为单位stats uri &lt;prefix&gt; #自定义stats page
#--------------------------------------------------------------------- #默认配置 #--------------------------------------------------------------------- defaults #默认的模式【tcp:4层; http:7层; health:只返回OK】 mode http #继承全局的日志定义输出 log global #日志类别, httplog option httplog option dontlognull option http-server-close option forwardfor except 127.0.0.0/8 option redispatch retries 3 timeout http-request 10s
文章目录一、概述二、实验目的三、实验拓扑四、实验环境五、实验配置5.1、haproxy服务器配置5.2、nginx服务器1配置5.3、nginx服务器2配置六、验证 软件包,Nginx和haproxy需要的自取 链接:https://pan.baidu.com/s/19oS_In0GvbqQzJU5VfPupw 提取码:f2ed 复制这段内容后打开百度网盘手机App,操作更方便哦 Haproxy是一款可提供高可用性、负载均衡、及基于TCP和HTTP应用的代理软件 适合于负载特别大的Web站点 运行在当前的硬件上可支持数以万计的并发连接请求 二、实验目的 当高并发请求来临时,hapro
Mar 5, 2016 keepalived、haproxy、mycat的下载安装配置运行,rsyslog的配置运行与测试,简单的haproxy健康检查,haproxy监控,系统访问测试,切换过程中的影响,和部署过程中的注意事项 refere
下载地址:https://src.fedoraproject.org/repo/pkgs/haproxy/本次使用的是 2.4.17 版本 HAProxy 是由 C 语言开发的,所以这里要安装 gcc gcc-c++ 3. 创建配置文件 1️⃣ 自己创建配置文件 2️⃣ 或者在解压目录下拷贝文件 4. 编写日志输出文件 5. 启动 HAProxy 👉 验证是否启动成功 6. 配置 systemctl 管理 7. 访问控制面板...
根据功能和用途将haproxy分为了5个部分,这五个部分不都是必须的,可以根据需要选择就行了,只是将haproxy完整的配置分为了五个部分,这样配置起来全局感就会很强(本文只介绍五个部分作用,不对参数进行细说) (1)global部分 用来设定全局配置参数,属于进程级的配置,通常和操作系统配置有关。 global log 127.0.0.1 local2 info pidfile /var/run/haproxy.pid maxconn ...
CSDN-Ada助手: 非常感谢博主的辛勤劳动和对Linux下Ngxin服务器防DDos攻击的研究。这篇博客内容生动详实,让人受益匪浅。同时也对博主的技术水平和分享精神表示肯定。期待博主再接再厉,分享更多有价值的知识。 为了方便博主创作,提高生产力,CSDN上线了AI写作助手功能,就在创作编辑器右侧哦~(https://mp.csdn.net/edit?utm_source=blog_comment_recall )诚邀您来加入测评,到此(https://activity.csdn.net/creatActivity?id=10450&utm_source=blog_comment_recall)发布测评文章即可获得「话题勋章」,同时还有机会拿定制奖牌。 信创国产中间件概览 一顿三碗: 没准还是包了一个壳 Linux单机使用本地镜像创建KVM虚拟机实例 秋刀鱼_天官: Xshell不需要花钱,有破解版 IBM WAS 简介 cnskylee: Jboss早就改名了,现在叫Wildfly IBM WAS 简介 cnskylee: JBoss早就淘汰了,以前被挖矿整的好惨。现在的名字叫wildfly