简体   繁体   English

Apache Mod-proxy负载均衡器维护

[英]Apache mod-proxy load balancer maintenance

I have mod-proxy and mod-proxy-balancer setup as a load balancing reverse proxy. 我将mod-proxy和mod-proxy-balancer设置为负载平衡反向代理。 Something like this: 像这样:

<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

Is there a simple way to set this up to show a static maintenance page when all members of the balancer group are down? 当平衡器组的所有成员都关闭时,是否有一种简单的方法可以将其设置为显示静态维护页面? I've done that with a hardware load balancer previously and it was very useful. 以前,我已经使用硬件负载平衡器完成了此操作,这非常有用。

Maybe you can use a hot standby. 也许您可以使用热备用。 The example below is from the ProxyPass Directive section where it says "Setting up a hot-standby, that will only be used if no other members are available" 下面的示例来自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>

As an alternative to RewriteRule you can do the same thing with appropriate ErrorDocument directives. 作为RewriteRule的替代方法,您可以使用适当的ErrorDocument指令执行相同的操作。 We do something like this in which the proxy server itself hosts static error pages and the "hot-standby" host is http://localhost/some-app/ . 我们执行类似的操作,其中代理服务器本身托管静态错误页面,而“热备用”主机为http:// localhost / some-app /

Since your proxy seems to be the only page (probably in a VirtualHost), you can simply override error pages. 由于代理似乎是唯一的页面(可能在VirtualHost中),因此您可以简单地覆盖错误页面。 Apache produces a 503 error, so this would look like: 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

If you want to use images inside the maintenance html, please not that you have to use absolute paths (eg /image.jpg) will load /var/www/html/image.jpg. 如果要在维护html中使用图像,请不要使用绝对路径(例如/image.jpg)来加载/var/www/html/image.jpg。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM