如何在HAProxy 1.6.4中在与前端相同的端口上运行统计信息? [英] How to run stats in HAProxy 1.6.4 on same port as frontend?

查看:62
本文介绍了如何在HAProxy 1.6.4中在与前端相同的端口上运行统计信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用HAProxy 1.6.4,并希望启用统计信息. (/haproxy?stats)

I'm using HAProxy 1.6.4 and want to enable the stats. (/haproxy?stats)

这是我的cfg:

global
   log 127.0.0.1 local2
   daemon
   maxconn 256

defaults
   log global
   timeout connect  5000
   timeout client  10000
   timeout server  10000

frontend http-in
   bind *:8080
   default_backend testb

backend testb
   balance roundrobin
   server s1 123.456.789.0:443 maxconn 32
   server s2 123.456.789.1:443 maxconn 32

listen statistics
   bind *:8080
   mode http
   stats enable

如果我在除8080之外的其他端口上运行统计信息,它可以工作,但是如何在与默认运行于mode tcp的前端(8080)相同的端口上运行统计呢?

If I run statistics on other port than 8080 it works, but how can I run it on the same port as my frontend (8080), which is running in the default mode tcp?

推荐答案

您可以通过重定向到自己并使用如下访问列表来做到这一点:

You can do it by redirecting to your self and using access list like this:

global
   log 127.0.0.1 local2
   daemon
   maxconn 256

defaults
   log global
   timeout connect  5000
   timeout client  10000
   timeout server  10000

listen stats :1936
   mode http
   stats enable
   stats hide-version
   stats realm Haproxy\ Statistics
   stats uri /
   stats auth myUser:myPassword

frontend http-in
   bind *:8080
   acl is_www hdr_end(host) -i www.mysite.com
   acl is_stat hdr_end(host) -i stat.mysite.com  

   use_backend srv_www if is_www
   use_backend srv_stat if is_stat

backend srv_www
   balance roundrobin
   server s1 123.456.789.0:443 maxconn 32
   server s2 123.456.789.1:443 maxconn 32

backend srv_stat
   server Local 127.0.0.1:1936

使用www转到服务器时,它将带您到Web服务器. 但是使用stat,它将您从输入端口8080重定向到1936运行状态

When going to your server with www, it takes you to the web server. But using stat, it redirects you from your input port 8080 to 1936 whee stat is running

这篇关于如何在HAProxy 1.6.4中在与前端相同的端口上运行统计信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆