mod_proxy 超时 (502) 和故障转移
因此,我们正在运行一个由 2 个以上后端服务器(恰好是 JBoss 服务器)组成的集群,这些服务器由 Apache 2.2 进行负载平衡。 有时,后端服务器可能会变得无响应(这意味着它们将等待很长时间才能回复请求,但不会立即关闭连接)。 这自然会导致 502“Bad gateway”错误。 我对负载均衡器的理解是,它应该进行故障转移并将请求重定向到其余实例。
我已经看到平衡器的节点可以进入错误状态,但永远无法强制将其发送到该状态(即在遇到第一个 502 后执行此操作)。 我错过了什么还是这只是我想要的功能? 哦,这是我的配置:
<Proxy balancer://s>
Order deny,allow
Allow from all
BalancerMember http://host1:8080/ route=h1 timeout=20 retry=40
BalancerMember http://host2:8080/ route=h2 timeout=20 retry=40
</Proxy>
# Distribute by Round Robin, use Sticky Sessions
ProxyPass / balancer://s/ stickysession=JSESSIONID lbmethod=byrequests nofailover=On
ProxyPassReverse / http://host1:8080/
ProxyPassReverse / http://host2:8080/
最好, 塞巴斯蒂安
so we're running a cluster of 2+ backend servers (happend to be JBoss servers) that are being load-balanced by an Apache 2.2. From time to time it can happen that the backend servers become unresponsive (meaning they'll wait ages to reply to a request, but don't close the connection immediately). This will naturally end up in a 502 "Bad gateway" error. My understanding of a load-balancer that is, that it should fail-over and redirect requests to the remaining instances.
I've seen that a node of the balancer can go to error state, but was never able to force-fully send one into that state (i.e. do that after the first 502 has been encountered). Am I missing something or is that just a feature I am wishing for?
Oh, and here goes my config:
<Proxy balancer://s>
Order deny,allow
Allow from all
BalancerMember http://host1:8080/ route=h1 timeout=20 retry=40
BalancerMember http://host2:8080/ route=h2 timeout=20 retry=40
</Proxy>
# Distribute by Round Robin, use Sticky Sessions
ProxyPass / balancer://s/ stickysession=JSESSIONID lbmethod=byrequests nofailover=On
ProxyPassReverse / http://host1:8080/
ProxyPassReverse / http://host2:8080/
Best,
Sebastian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您指定 nofailover=On 这意味着它不会进行故障转移,因此会出现 502 错误。 如果您希望它进行故障转移,则需要设置 nofailover=Off 这意味着它应该进行故障转移。
You specified nofailover=On which means it won't failover, hence the 502 errors. If you want it to failover it needs to be nofailover=Off which means it should failover.