diff --git a/Caddyfile b/Caddyfile index f2a8f2372..2e1528610 100644 --- a/Caddyfile +++ b/Caddyfile @@ -8,10 +8,26 @@ # ca https://acme-staging-v02.api.letsencrypt.org/directory # } - + # Removing some headers for improved security: header -Server + @noRedirect { + not path /maintenance.html + not path /offline.png + } + @maintenanceModeActive file { + root /srv + try_files maintenance.on + } + handle @maintenanceModeActive { + root * /srv + redir @noRedirect /maintenance.html + file_server { + status 503 + } + } + # Serves static files, should be the same as `STATIC_ROOT` setting: root * /var/www/django file_server @@ -21,6 +37,7 @@ not path /media/* } + # Serving dynamic requests: reverse_proxy @noStatic django:8000 diff --git a/docker-compose.yml b/docker-compose.yml index 9b96f9590..cc8109952 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,7 @@ services: - ./caddy_data:/data - ./caddy_config:/config - ./var/log/caddy:/var/log/ + - ./maintenance_mode/:/srv restart: unless-stopped ports: - 80:80 diff --git a/maintenance_mode/maintenance.html b/maintenance_mode/maintenance.html new file mode 100644 index 000000000..e300ec782 --- /dev/null +++ b/maintenance_mode/maintenance.html @@ -0,0 +1,19 @@ + + +
+
+ Sorry, the page you are looking for is currently unavailable because the site is undergoing maintenance.
+Please try again later. Thank you.
+ + \ No newline at end of file diff --git a/maintenance_mode/offline.png b/maintenance_mode/offline.png new file mode 100644 index 000000000..837974125 Binary files /dev/null and b/maintenance_mode/offline.png differ