AWS load balancer and maintenance page

时间秒杀一切 提交于 2019-12-21 03:38:19

问题


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

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.

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).

My questions are:

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) Or how to configure Load Balancer's Health Check that it will not consider 503 as a reason to mark server as "unhealthy"?

Thanks!


回答1:


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.




回答2:


Might not meet your 503 requirement but a good option for this is using s3 and dns failover: https://aws.amazon.com/blogs/aws/create-a-backup-website-using-route-53-dns-failover-and-s3-website-hosting/




回答3:


The load balancer will serve a 503 for you when you no longer have any healthy server behind it so you should not do anything special.

If you return anything but a 200 on the health check, ELB will take the machine out of the load balancer after it fails the configured number of health checks.

So to recap, you can potentially serve 503 from your app when in maintenance, but you have to return 200 for health checks all the time. If you don't care about the content of the page, you can simply remove the machines from the load balancer (or fail health checks) and the LB will do the right thing for you.



来源:https://stackoverflow.com/questions/32343136/aws-load-balancer-and-maintenance-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!