gpt4 book ai didi

frontend - HAProxy 如何将 "stick-table"ip 连接到同一后端?

转载 作者:行者123 更新时间:2023-12-02 01:57:36 25 4
gpt4 key购买 nike

我的 HAProxy 配置:

global
maxconn 300000

defaults
mode http
log global
option httplog
option http-server-close
option dontlognull
option redispatch
option contstats
retries 3
backlog 10000
timeout client 5s
timeout connect 5s
timeout server 5s
timeout tunnel 120s
timeout http-keep-alive 5s
timeout http-request 15s
default-server inter 3s rise 2 fall 3
option forwardfor

frontend ft_web
bind *:8000 name http
maxconn 300000
stick-table type ip size 5000k expire 5m store conn_cur
tcp-request connection reject if { src_conn_cur ge 3 }
tcp-request connection track-sc1 src
default_backend bk_web

backend bk_web
balance roundrobin

server s8001 127.0.0.1:8001 maxconn 500 weight 10 cookie s8001 check
server s8002 127.0.0.1:8002 maxconn 500 weight 10 cookie s8002 check
server s8003 127.0.0.1:8003 maxconn 500 weight 10 cookie s8003 check
server s8004 127.0.0.1:8004 maxconn 500 weight 10 cookie s8004 check

目前,如果有人打开超过 3 个连接,所有其他连接都会被丢弃,但我需要将 IP 固定到后端,所以每次有人使用相同的 IP 访问前端时,他都会转到相同的后端节点 ...

谢谢

最佳答案

你只是错过了坚持和坚持火柴的部分。我的配置如下所示:

global
maxconn 300000

defaults
mode http
log global
option httplog
option http-server-close
option dontlognull
option redispatch
option contstats
retries 3
backlog 10000
timeout client 5s
timeout connect 5s
timeout server 5s
timeout tunnel 120s
timeout http-keep-alive 5s
timeout http-request 15s
default-server inter 3s rise 2 fall 3
option forwardfor

frontend ft_web
bind *:8000 name http
maxconn 300000
stick-table type ip size 5000k expire 5m store conn_cur
stick on src table bk_web
tcp-request connection reject if { src_conn_cur ge 3 }
tcp-request connection track-sc1 src
default_backend bk_web

backend bk_web
balance roundrobin

stick match src table bk_web
server s8001 127.0.0.1:8001 maxconn 500 weight 10 cookie s8001 check
server s8002 127.0.0.1:8002 maxconn 500 weight 10 cookie s8002 check
server s8003 127.0.0.1:8003 maxconn 500 weight 10 cookie s8003 check
server s8004 127.0.0.1:8004 maxconn 500 weight 10 cookie s8004 check

关于frontend - HAProxy 如何将 "stick-table"ip 连接到同一后端?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19114976/

25 4 0