gpt4 book ai didi

apache - 具有 SSL (https) 和粘性 session 的 HAProxy

转载 作者:太空宇宙 更新时间:2023-11-03 13:28:50 25 4
gpt4 key购买 nike

我需要设置负载均衡器作为 ELB for Amazon 的替代方案,因为它们存在连接超时问题。

目前,我正在使用 HAProxy,它工作正常。但是,对于想要通过 https(端口 443)连接到后端 Apache 服务器以及粘性 session 的用户,我需要使用 SSL。

配置会是什么样子?我听说 HAProxy 在 native 中不支持 SSL,可以使用 stunnel 或 nginx/apache 来处理 SSL 终止。

我很感激任何人分享他们的知识和经验。

谢谢。詹姆斯

最佳答案

对于 http 使用类似的东西。将 XXX.XXX.XXX.XXX 更改为您的 IP 地址。

listen  example-cluster XXX.XXX.XXX.XXX:80
mode http
stats enable
stats auth user:password
stick store-request src
stick-table type ip size 200k expire 2m
balance source
cookie JSESSIONID prefix
option httplog
option httpclose
option forwardfor
option persist
option redispatch
option httpchk HEAD /check.txt HTTP/1.0
server example-webl XXX.XXX.XXX.XXX:80 cookie A check
server example-web2 XXX.XXX.XXX.XXX:80 cookie B check
server example-web3 XXX.XXX.XXX.XXX:80 cookie C check
server example-web4 XXX.XXX.XXX.XXX:80 cookie D check
server example-web5 XXX.XXX.XXX.XXX:80 cookie E check

对于您的 SSL,请使用带有余额源的 tcp 模式:

listen  example-cluster-ssl XXX.XXX.XXX.XXX:443
mode tcp
reqadd X-Forwarded-Proto:\ https
stick store-request src
stick-table type ip size 200k expire 2m
option persist
option redispatch
option ssl-hello-chk
balance source
server example-webl XXX.XXX.XXX.XXX:443 check
server example-web2 XXX.XXX.XXX.XXX:443 check
server example-web3 XXX.XXX.XXX.XXX:443 check
server example-web4 XXX.XXX.XXX.XXX:443 check
server example-web5 XXX.XXX.XXX.XXX:443 check

另一种方法是将 haproxy 升级到 1.5 版,该版本支持 ssl 但还不稳定。

关于apache - 具有 SSL (https) 和粘性 session 的 HAProxy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12048667/

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