AWS负载平衡器和维护页面 [英] AWS load balancer and maintenance page

查看:145
本文介绍了AWS负载平衡器和维护页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将AWS Load Balancer与3台EC2服务器一起使用,并且当站点处于维护状态时,我试图提供维护"页面.

I'm using AWS Load Balancer with 3 EC2 servers, and I'm trying to serve a Maintenance page when site is under maintenance.

此页面需要返回503 HTTP代码,因为它是维护模式的正确代码,并且可以防止SEO出现问题.

This page need to return 503 HTTP code, because it is a proper code for a maintenance mode and will prevent possible problems with SEO.

当我从任何一台服务器返回503代码时,Load Balancer使其变为未投入使用",而当所有服务器返回503时,网站将返回空白页(因为所有服务器均已断开连接).

When I return 503 code from any of my servers, Load Balancer makes it "Not In Service", and when all servers return 503, website returns a blank page (because all servers are disconnected).

我的问题是:

1)如果没有正常运行的服务器,是否可以通过Load Balancer向访问者的消息提供自定义静态页面?

1) Is there any way to serve a custom static page with a message for visitors from Load balancer if there is no healthy servers?

2)或如何配置负载均衡器的运行状况检查,以使其不会将503视为将服务器标记为不正常"的原因?

2) Or how to configure Load Balancer's Health Check that it will not consider 503 as a reason to mark server as "unhealthy"?

谢谢!

推荐答案

您可以在应用服务器中实现一条附加路由,例如/hcm(用于运行状况检查维护),该路由始终会响应200 OK.在需要维护时,可以通过编程方式修改ELB运行状况检查,以使用/hcm目标返回200 OK,而不是/或/index.html,后者均返回503 Service Unavailable.退出维护时还原这些更改.

You could implement an additional route in your app server, let's say /hcm (for health check maintenance), that always responds 200 OK. When it's time for maintenance, you programmatically modify the ELB health check to use the /hcm target which returns 200 OK rather than / or /index.html, which both return 503 Service Unavailable. Revert these changes when exiting maintenance.

这篇关于AWS负载平衡器和维护页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆