AWS 负载均衡器和维护页面

编程入门 行业动态 更新时间:2024-10-28 08:21:09
本文介绍了AWS 负载均衡器和维护页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我将 AWS 负载均衡器与 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 代码时,负载均衡器使它不在服务中",当所有服务器返回 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) 如果没有健康的服务器,有没有办法为来自负载均衡器的访问者提供带有消息的自定义静态页面?

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 运行状况检查以使用返回 200 OK 的/hcm 目标,而不是返回 503 Service Unavailable 的/或/index.html.退出维护时恢复这些更改.

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 负载均衡器和维护页面

本文发布于:2023-11-01 20:48:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550377.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:均衡器   负载   页面   AWS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!