Question

How set up a maintenance page when droplet is off, restarting or not responding to a specific port?

Posted February 26, 2020 678 views
DigitalOcean Accounts

Consider the following:
I have a Droplet currently working and configured, with a domain pointing to it, serving something from some port (for e.g. nginx serving a website on 80/443, or a mySQL on 3306).

I’d like to configure for the domain a 503 (Service Unavailable) page when Droplet is currently Turned off, is in a process (for e.g. restarting, re-scaling) or when it’s not serving something on said port (for e.g, Droplet is on but mysql or nginx daemons are off because either crashed or I’m currently giving maintenance).

How can I serve said HTTP response on each of these cases?
This is a lot better than simply having the domain give dns/timeout error.

Thank you.

This question from 2014 asks the same thing, but the response given totally hit the mark, like the person didn’t even try to read the question and just blindly answered the inner questions, which were suppositions/thoughts.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi there @RaphaelDDL,

As the Droplet would be down, you would need another service in front of the actual Droplet that would be able to serve a maintenance page for example.

There are a couple of things that I could suggest:

  • You could use HAProxy, that way you would point your Domain name to the HAProxy server and it would proxy the traffic to your Droplet, if the Droplet goes down, HAProxy would not be able to connect anymore and it would throw a 503 error. You would be able to change that error with a more meaningful message, you can take a look at this answer here on how to do that:

https://www.digitalocean.com/community/questions/haproxy-change-503-page-with-a-custom

If you decide to go with that option, you could take a look at this introduction tutorial here:

https://www.digitalocean.com/community/tutorials/an-introduction-to-haproxy-and-load-balancing-concepts

If you are not familiar with HAProxy, you could achieve the same setup with Nginx as well.

  • Another option would be to use a CDN like Cloudflare, there is a page that Cloudflare shows when the backend Droplet is down and, on the Pro plan and above, is customizable:

http://cloudflarepreview.com/preview-cpage?act=preview&target=cf-error%3A500s

Hope that this helps!
Let me know if you have any questions.
Regards,
Bobby

by Mitchell Anicas
An introduction to basic load balancing concepts and terminology, using HAProxy, with some examples.
  • Hi Bobby, thank you for your time replying.

    Yes, so I currently use CloudFlare as my CDN and yes, the exact reason of my question was because CF only allows custom pages on paid plans, and I use the free one.

    I would assume that DO could offer a custom error page for their services too since we can configure the DNS/domain to the specific Droplet.. And if that was the case, then they can do the same as CF and offer error pages.

    That’s the only reason I still didn’t point my domains to the DO Nameservers directly instead of CF’s ones. Since seems they don’t offer, I guess I’ll have to stick to CF’s default ones then…

    The first paid CF plan is $20/month, that’s pretty much was I was paying for everything before moving to DO (Heroku Dynos, a Web hosting for assets, etc), now I’m only paying $5/month for the Droplet (but I’ll upgrade to the $15/mo for extra RAM), so paying $20 on CF is really not a possibility.

    I’ll definitely check HAProxy: maybe I can try make domain point to CF NS then CF point to HAProxy and HAProxy to the Droplet so I can serve custom pages without paying $20/mo only for that. Willingly or not, CF caching is still a very nice to have feature to save bandwidth. Just need to test how much this routing will affect page response time.

    Thank you very much!

Submit an Answer