gpt4 book ai didi

linux - 如何设置 HAProxy 以在匹配查询字符串键值时断开连接?

转载 作者:太空宇宙 更新时间:2023-11-04 12:06:05 24 4
gpt4 key购买 nike

我已经在 Centos 7 上安装了 HAProxy 1.5.18。

/etc/haproxy/haproxy.cfg 我有以下行:

frontend free_api
bind *:80
stats uri /haproxy?stats
mode http
option forwardfor
acl key1 urlp(key) 12345
acl key2 urlp(key) 6789

http-request deny if key1
http-request deny if key2

# use_backend api if api
default_backend api

现在,对于匹配值为 123456789 的查询字符串键,URL 访问被拒绝。 HAProxy 返回一个 403 Forbidden 状态码。

我正在寻找的是简单地断开连接,这样就不会向用户返回任何内容?如何在 HAProxy 中做到这一点?

谢谢。

最佳答案

使用 haproxy v1.6 及更高版本,以及指令 silent-drop

http-request silent-drop if key1

"silent-drop" : this stops the evaluation of the rules and makes the client-facing connection suddenly disappear using a system-dependent way that tries to prevent the client from being notified. The effect it then that the client still sees an established connection while there's none on HAProxy. The purpose is to achieve a comparable effect to "tarpit" except that it doesn't use any local resource at all on the machine running HAProxy. It can resist much higher loads than "tarpit", and slow down stronger attackers. It is important to understand the impact of using this mechanism. All stateful equipment placed between the client and HAProxy (firewalls, proxies, load balancers) will also keep the established connection for a long time and may suffer from this action. On modern Linux systems running with enough privileges, the TCP_REPAIR socket option is used to block the emission of a TCP reset. On other systems, the socket's TTL is reduced to 1 so that the TCP reset doesn't pass the first router, though it's still delivered to local networks. Do not use it unless you fully understand how it works.

关于linux - 如何设置 HAProxy 以在匹配查询字符串键值时断开连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50650678/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com