Maintenance Mode

There are many cases where the website should be temporarily brought down.
Moving server, software upgrade that requires an outage, you name it.
It would be natural and logical if Maintenance Mode could be turned on in the Cloudflare admin console.
Is there a way to turn on maintenance mode directly on Cloudflare?

What would a Maintenance Mode do?

Maintenance Mode would display a static landing page to all users trying to access the website.

E.g. ā€œSite is temporarily offline for maintenance, please come back later.ā€

In the meantime site admin could safely do their job, migrate the DB, etc.

5 Likes

This sounds like a job for a Cloudflare App, though if all users got the Maintenance mode page, I’m not sure how you’d be able to admin the site.

Admin could add their ip-address in CF as an exception or access the site directly by IP-address.

3 Likes

Is what you are describing something like Always Online, but with the option to customize the page and deploy on demand?

I don’t think so (though I haven’t tried), as AO is not likely to start working on demand on dynamic pages that were previously uncached. Edge servers will not have cached versions of such pages, and while site is offline, there is nowhere to get those pages from. Also all form submissions will fail leaving users in frustration, as they will not know what happens and why. Overall, this option does not look like an adequate replacement for the Maintenance Mode.

Anyway, can’t tell for sure, depends on how exactly it’s is going to be implemented. What I suggest is a simple solution that switches the site off for a while replacing all URLs with one static page. There may be options, like ā€œturn MM on for all sites on this ip-addressā€, but overall it should be simple I believe.

Sorry. I didn’t mean to suggest it would work now. Just if that tech could be leveraged somehow.

This is more or less possible with custom error pages and lockdown rules. Lockdown rules display the IP/Country custom block page to visiting clients, so if you create a lockdown rule for your entire domain and only allow access to your own IP, you can use the custom block page to display a maintenance message.

This isn’t perfect, as there’s no separate customization option for the maintenance page, so you’d need to swap out that page with the default or your normal custom block page every time you close the site for maintenance. Lockdown rules are also currently API-only, so there’s no simple button in the UI to start/end maintenance.

1 Like

I cant imagine why this doesn’t exist already. Asking ā€œwhat would it do?ā€ seems a little unnerving, since it is one of the most common things in the world for web applications to need?

3 Likes

Add a Maintenance Mode and display a specifc page for single domain, subdomain or all site, in case of transfer hosting or others i think is a good idea =)

1 Like

You could easily do this with Cloudflare workers - Here’s an example :slight_smile:

https://www.resdevops.com/2018/03/20/Cloudflare-workers-maintenance-mode-static-page/

Workers are pretty powerful and affordable.

9 Likes

Sweet!

IS this already available? Would be nice, if you’re going to have a huge maintance on your dedicated server. For example new install OS from scrach, etc.

Page Rules and Workers can handle this pretty good already.

I wouldn’t even bother with a Page Rule. I’d use an HTML worker and assign it to the route *example.com/*

HTML for a page can contain embedded CSS and Images/favicon, even. Then you’d have a single-resource Maintenance page.

1 Like

There’s a simple Terraform module to create a maintenance page GitHub - adinhodovic/terraform-cloudflare-maintenance: Terraform module to create a responsive Maintenance Page using Cloudflare Workers.. Creates a worker, route and a static html page.

It is a good suggestion for maintenance mode on-demand, but how automatically reroute traffic from app.subdomains.com to my worker if something wrong with the subdomain origin?

I am a bit baffled as well this isn’t a feature. Basically just a easy switch like you have for ā€˜development mode’ and ā€˜I am under attack’. If you could just turn on maintenance mode which would redirect all traffic to a static html page, or even just a specific URL. All I need to do is do a server upgrade and restart the server, so would be nice to easily and quickly be able to turn on/off maintenance mode. I have looked at some of the tutorials for workers and routes, however it doesn’t look so easy! Guess I’ll have to set aside time to figure it out…