SETUP: serving this maintenance page the right way
==================================================

While your site is down, send this page with HTTP status 503 (Service
Unavailable) and a Retry-After header, not a normal 200. Search engines
read 503 as "temporarily down, come back later" and keep your pages
indexed. The page also carries <meta name="robots" content="noindex">.

1. Upload the files to a /maintenance/ folder on your site.
2. The page may be shown at any URL, so in index.html change the relative
   links to absolute ones: href="style.css" -> href="/maintenance/style.css"
   (same for favicon.svg and any script.js).
3. Use one of the setups below. Retry-After is in seconds (3600 = 1 hour).

nginx (create the file /var/www/maintenance.on to switch it on)
-----
    location /maintenance/ { }   # its CSS/JS load normally
    location = /maintenance/index.html {
        add_header Retry-After 3600 always;
    }
    location / {
        if (-f /var/www/maintenance.on) { return 503; }
        # ...your normal config...
    }
    error_page 503 /maintenance/index.html;

Apache (.htaccess; create maintenance.on in the site root to switch it on)
------
    RewriteEngine On
    RewriteCond %{DOCUMENT_ROOT}/maintenance.on -f
    RewriteCond %{REQUEST_URI} !^/maintenance/
    RewriteRule ^ - [R=503,L]
    ErrorDocument 503 /maintenance/index.html
    Header always set Retry-After "3600" "expr=%{REQUEST_STATUS} == 503"

Cloudflare Pages
----------------
A _headers file can add headers but cannot change the status code, so use
a small Function. Save as functions/_middleware.js, then set the
environment variable MAINTENANCE=on (and redeploy) to switch it on:

    export async function onRequest({ request, next, env }) {
      if (env.MAINTENANCE !== 'on') return next();
      const url = new URL(request.url);
      if (url.pathname.startsWith('/maintenance/')) return next();
      const page = await env.ASSETS.fetch(new URL('/maintenance/', url));
      return new Response(page.body, { status: 503, headers: {
        'Content-Type': 'text/html; charset=utf-8',
        'Retry-After': '3600', 'Cache-Control': 'no-store' } });
    }

A Cloudflare Worker in front of any host works the same way: fetch
/maintenance/ and return it with status 503 and Retry-After.

Switch it off by deleting maintenance.on (or setting MAINTENANCE=off).
