Reputation: 2667
I would like to have a custom "under maintenance" page show up if my webservers on EC2 go down.
My current setup 2 A records on Route 53, using DNS Failover with a static page as the secondary and the ELB instance as the primary.
The problem with this is DNS caching - when the server first goes down, the default 502 error appears for a while for clients who were recently on the page. It takes around 5 minutes for our custom maintenance page to show up for them. When the servers come back up, it also takes around 5 minutes for the maintenance page to go away.
The first problem is more pressing for me - I don't want users to see a plain "502 Bad Gateway" message, ever. If they visit our site and things are broken or down, they should always see our custom maintenance HTML page, regardless of whether the ELB targets went down half a second ago or 10 minutes ago.
How can I make it so that if my ELB instance returns a 502, the users will automatically see a custom error page 100% of the time, so that they never see the default "502 Bad Gateway" error page?
Upvotes: 6
Views: 6487
Reputation: 31
We are trying to configure this same thing for our web application. We see the exact same enhancement request pending with AWS since a long time: https://forums.aws.amazon.com/thread.jspa?threadID=72363&start=125&tstart=0
The other option is to use cloudfront for the whole application (not just static content) and configure custom pages for specific error codes: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages-procedure.html; we don't like this option for multiple reasons, one of which is the added complexity.
So, at this time, it looks like we will have to live with this default 502 page.
Upvotes: 3