Articles of haproxy

HAProxy + RabbitMQ,保持连接活着

我正在尝试将HAProxy设置为RabbitMQ群集上的负载平衡器。 我使用这样的configuration: global log /dev/log local0 debug log /dev/log local1 debug chroot /var/lib/haproxy user haproxy group haproxy defaults log global retries 2 timeout connect 5000 timeout server 50000 timeout client 50000 listen rabbitmq-cluster bind my.pu.blic.ip:5672 mode tcp option tcpka option redispatch balance roundrobin server rabbit1 rabbit1:5672 check inter 5000 downinter 500 server rabbit2 rabbit2:5672 check […]

使用命令行从HAProxy添加/删除后端服务器

我一直在寻找一种方法来添加和删除从HAProxy的后端服务器dinamically,有包装,甚至是一个API来处理它? 我想用HAProxy和DigitalOCean制作一个自动缩放系统。 其他负载均衡器是受欢迎的。

在Linux上configurationHAProxy以接受10K同时连接

我有Ubuntu 14.04(修改)上运行的HAProxy 1.5。 它接受http和https端口上的连接。 两个后端应用程序使用持久连接处理请求。 当我创build大约2200个客户端连接时,haproxy停止接受其他连接。 但是我希望这个系统能够接受至less10K个同时连接。 这里是连接统计: # ss -s TCP: 4119 (estab 4098, closed 6, orphaned 0, synrecv 0, timewait 6/0), ports 0 Transport Total IP IPv6 TCP 4113 4106 7 INET 4128 4117 11 我已经调整过程的最大打开文件数量: # cat /proc/1012/limits Limit Soft Limit Hard Limit Units Max open files 240017 240017 files 我的haproxy.config文件: global […]

HAproxy mysql故障转移

我尝试使用Percona xtraDB Cluster for MySQL复制和HAproxy来设置HA集群以实现负载平衡。 HAproxy对于apache非常有效,当apache崩溃或者没有响应时,HAproxy会在另一个节点上进行切换。 我的问题从MySQL开始,我也在相同的HAproxy中设置MySQL,但是当MySQL没有响应时,HAproxy不会切换到另一个节点。 然而,HAproxy看到,MySQL检查HAproxy状态MySQL服务器closures时,不响应原因。 我的问题是,是否有可能在HAproxy中设置两个资源? 他可以检查apache是​​否启动,如果没有启动另一个节点,检查MySQL是否启动,如果没有则启动另一个节点? HAproxy.conf: […] frontend redmine bind 192.168.7.149:80 reqadd X-Forwarded-Proto:\ http default_backend redmine frontend redmineS bind 192.168.7.149:443 ssl crt /etc/ssl/private/quipment.fr.pem reqadd X-Forwarded-Proto:\ https default_backend redmine backend redmine 192.168.7.149:80 redirect scheme https if !{ ssl_fc } mode http balance roundrobin option http-server-close timeout http-keep-alive 3000 option forwardfor cookie […]

Apache HTTPD的remoteip无法正常工作

我configuration了remoteip,并检查它是否实际加载。 remoteip.conf也被加载。 我通过在下面的(正确)configuration中引入错误格式化的IP来检查后者: RemoteIPHeader X-Forwarded-For RemoteIPTrustedProxy 127.0.0.1 10.10.0.1 10.10.0.2 现在,当一个最终用户加载,我可以validation我看到X-Forwarded-For头的值10.10.255.100这是正确的。 但PHP中的REMOTE_ADDRvariables仍然是负载均衡器的IP地址。 根据每个教程,在这个问题上应该简单地在这一点上工作。

使用haproxy per url per ip来限制速度

我们的服务器不断遭到某人的袭击。 它不是DDOS。 只有一个IP每秒超过200次的url。 目前我正在通过ip表阻止用户。 我们正在使用HAproxy进行负载平衡。 有没有办法限制一个用户的基础上,他的IP和url被击中? 我不想阻止基于IP,因为NAT的用户可能会受到影响。 假设我想显示503错误页面,如果一个特定的IP在5分钟内击中了像www.example.com/somepage.php?some=option&other=option2超过3000次的相同的url? 这意味着相同的IP可以访问其他url,如www.example.com/somepage.php?another=someotheroption。

Haproxy 301 URL在查询string条件下redirect

使用在Ubuntu 12.04上运行的Haproxy 1.5.12 我的网站得到很多像这样的请求: http://www.example.com/foo/bar/mypage.php?gallery=&position=3 正确的URL应该是: http://www.example.com/foo/bar/mypage.php?gallery=photogallery&position=3 我已经成功地将请求重写到正确的URL,但我也想发出301redirect到客户端。 以下这篇文章: 使用haproxyredirect重写的URL我试过: acl fix_gallery url_sub gallery=& reqrep (.*)gallery=&(.*) \1gallery=photogallery&\2 redirect prefix / code 301 if fix_gallery 试图有创意我试过了: acl fix_gallery url_reg (.*)gallery=&(.*) acl fix_gallery urlp_reg(gallery) -m str "" acl fix_gallery urlp_reg(gallery) -m len 0 还有很多。 但似乎没有任何工作,所以我显然失去了一些东西。 有什么build议么? 谢谢

基于标题值的HAProxydynamic服务器地址

你好我试图路由stream量回到用户机器为了在本地运行一个站点,但拿起HAProxy提供的其他来源的标头/ cookies /路由逻辑。 到目前为止,我还没有弄清楚如何做到这一点。 该文档说使用环境variables是可用的https://cbonte.github.io/haproxy-dconv/configuration-1.5.html#4-server 地址string的任何部分都可以引用任意数量的环境variables,方法是使用美元符号('$')在名称前加上括号('{}'),类似于Bourne shell中所做的。 但我会想象有一种使用acl或样本获取的方式,但对于我来说,我无法弄清楚如何去做。 下面是我尝试过的一个例子。 我通过删除$ {hdr(originalIp)}并使用我的IP做了一个概念validation,但是我希望它能dynamic地使用请求者IP(如果存在的话) ### Sample config acl has_local_cookie cook_sub(local) -i true use_backend local if has_local_cookie backend local server local-origin ${hdr(originalIp)}:443 ssl verify none

Haproxy http-buffer-request不起作用

我无法获得Haproxys http-buffer-request选项的工作。 我正在使用Haproxy 1.6.5。 这是我的configuration: global maxconn 20000 debug defaults HTTP mode http option http-buffer-request # buffer the whole request before dispatching it to the backend timeout connect 5s timeout client 50s timeout server 50s frontend http bind 127.0.0.1:8123 use_backend api.radioadmin_backend if { hdr(host) -i api.radioadmin.local:8123 } use_backend radioadmin_backend if { hdr(host) -i radioadmin.local:8123 } […]

添加一个mysql检查haproxy

我试图添加一个mysql检查haproxy,其中如果服务不可用,它将返回一个错误页面,就像下面的configuration与http服务器一样。 我只是不确定最好的方法。 基本上,如果所有的Web服务器都closures了,它应该返回错误文件,如果只是mysql服务器closures,它应该返回错误文件,即使所有的Web服务器都处于活动状态。 任何帮助表示赞赏。 frontent ft_app bind 10.0.0.1:80 # sorry page to return when worst case happens errorfile 503 /etc/haproxy/error.html # detect capacity issues in production farm acl MAIN_not_enough_capacity nb_srv(bk_app_main) le 2 # failover traffic to backup farm use_backend bk_app_backup if MAIN_not_enough_capacity default_backend bk_app_main backend bk_app_main server s11 10.0.0.101:80 check server s12 10.0.0.102:80 check backend […]