HAProxy 和“分片”
我想知道是否有人使用过 HAProxy 进行分片。 具体来说,我希望能够使用我定义的带有标识符的 cookie,并让任何提供该 cookie/标识符组合的客户端定向到同一服务器。 这似乎是可能的,我的初步测试似乎有效,但我不确定。
我的监听配置如下所示:
listen appli1-rewrite 0.0.0.0:80
cookie mysession= prefix
balance roundrobin
server app1_1 192.168.0.1:80 cookie server01
server app1_2 192.168.0.2:80 cookie server02
option httpclose
但是,当我使用 Live Http Headers 查看请求标头时,我没有看到 mysession cookie 指示它将前往哪个服务器,这是我根据前缀操作所期望的。 我对 HAProxy 很陌生,所以任何帮助/指导都会很棒!
I was wondering if anyone has used HAProxy for sharding.
Specifically, I would like to be able use a cookie I define w/a identifier and have any client that presents that cookie/identifier combination be directed to the same server. It seems possible and my preliminary tests seem to work but I am not a sure.
My listen configuration looks like:
listen appli1-rewrite 0.0.0.0:80
cookie mysession= prefix
balance roundrobin
server app1_1 192.168.0.1:80 cookie server01
server app1_2 192.168.0.2:80 cookie server02
option httpclose
However, when I look at the request headers using Live Http Headers I don't see the mysession cookie indicating which server it will be going to, which is what I expected based on the prefix operation.
I am quite new to HAProxy so any help/guidance would be great!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据HAProxy文档,我认为你需要稍微调整你的haproxy配置,让它插入cookie:
根据:
http://haproxy.1wt.eu/download/1.2/doc/architecture.txt
您需要类似:
cookie SERVERID 间接插入
According to the HAProxy docs I think you need to tweak your haproxy config a little, to have it insert the cookie:
According to:
http://haproxy.1wt.eu/download/1.2/doc/architecture.txt
You need something like:
cookie SERVERID insert indirect