1

我将 mod-proxy 和 mod-proxy-balancer 设置为负载平衡反向代理。像这样的东西:

<Proxy balancer://example>
    BalancerMember http://hostname:8000 keepalive=on
    BalancerMember http://hostname:8001 keepalive=on
</Proxy>

ProxyPass / balancer://example/
ProxyPassReverse / balancer://example/
ProxyPreserveHost on
ProxyRequests Off

有没有一种简单的方法来设置它以在平衡器组的所有成员都关闭时显示静态维护页面?我以前用硬件负载平衡器做过这个,它非常有用。

4

3 回答 3

4

也许您可以使用热备用。下面的示例来自ProxyPass 指令部分,其中显示“设置热备用,仅在没有其他成员可用时使用”

ProxyPass / balancer://hotcluster/
<Proxy balancer://hotcluster>
BalancerMember http://1.2.3.4:8009 loadfactor=1
BalancerMember http://1.2.3.5:8009 loadfactor=2
# The below is the hot standby
BalancerMember http://1.2.3.6:8009 status=+H
ProxySet lbmethod=bytraffic </Proxy>
于 2009-06-03T02:16:34.660 回答
1

作为 RewriteRule 的替代方法,您可以使用适当的 ErrorDocument 指令执行相同的操作。我们做了这样的事情,其中​​代理服务器本身托管静态错误页面,而“热备用”主机是http://localhost/some-app/

于 2009-11-12T21:44:31.853 回答
0

由于您的代理似乎是唯一的页面(可能在 VirtualHost 中),您可以简单地覆盖错误页面。Apache 产生 503 错误,因此如下所示:

# Document root is required because error documents use relative paths 
DocumentRoot /var/www/html/
# Allow access to document root directory
<Directory /var/www/html/>
  Order allow,deny
  allow from all
</Directory>
# Actual change: If service is unavailable (no member available), show this page
ErrorDocument 503 /maintenance.html

如果您想在维护 html 中使用图像,请不要使用绝对路径(例如 /image.jpg)将加载 /var/www/html/image.jpg。

于 2013-08-29T08:31:35.130 回答