在我的haproxyconfiguration我设置了一个大小为5的存储每个进入的IP地址(1分钟)的粘贴表,它被设置为nopurge所以新的条目将不会被存储在表中。 我想要发生的事情是他们会被拒绝,但是这并没有发生。
棒桌线是:
stick-table type ip size 5 expire 1m nopurge store gpc0
整个configuration是:
global maxconn 30000 ulimit-n 65536 log 127.0.0.1 local0 log 127.0.0.1 local1 debug stats socket /var/run/haproxy.stat mode 600 level operator defaults mode http timeout connect 5000ms timeout client 50000ms timeout server 50000ms backend fragile_backend tcp-request content track-sc2 src stick-table type ip size 5 expire 1m nopurge store gpc0 server fragile_backend1 ABCD:80 frontend http_proxy bind *:80 mode http option forwardfor default_backend fragile_backend
我已经确认(使用socat readline /var/run/haproxy.stat连接到haproxy的统计信息),表格中填充了5个IP地址,但是之后每个来自新IP的请求都会直接通过 – 它不是没有添加到粘贴表中,粘贴表中没有任何内容被删除,并且请求没有被拒绝。
我想要做的就是拒绝这个请求,如果stick-table已满。 这可能吗?
我正在使用haproxy 1.5。
正如我在另一个线程中所说的那样,这需要添加一个非常简单的ACL来报告表中使用的条目数。 我认为最多只有10行代码,包括函数声明,但是我们需要添加它。 我现在没时间了,所以我把这个添加到TODO列表中,如果有人找时间去做,我会接受一个贡献。
这听起来好像不是从文档的措辞方式应该发生的行为。 但也许你可以增加表中的每个IP的GPC,否认它是零?
src_get_gpc0(table) <integer> Returns the value of the first General Purpose Counter associated to the connection's source IPv4 address in the current proxy's stick-table or in the designated stick-table. If the address is not found, zero is returned. See also sc1/sc2_get_gpc0 and src_inc_gpc0.
这就是说你的后端被称为“fragile_backend”。 如果您试图限制与服务器的连接数量,因为服务器一次只能处理如此多的连接,您可能希望在服务器定义中使用maxconn参数。 使用这个,HAPRoxy会排队超过这个数量的连接。 你也可能对此有兴趣:
be_conn <integer> be_conn(backend) <integer> Applies to the number of currently established connections on the backend, possibly including the connection being evaluated. If no backend name is specified, the current one is used. But it is also possible to check another backend. It can be used to use a specific farm when the nominal one is full. See also the "fe_conn", "queue" and "be_sess_rate" criteria.