{"id":18011488,"url":"https://github.com/tmiland/nginx-maintenance-mode","last_synced_at":"2025-10-09T11:47:43.450Z","repository":{"id":70815499,"uuid":"178264266","full_name":"tmiland/Nginx-Maintenance-Mode","owner":"tmiland","description":"Easily toggle on or off maintenance mode with nginx","archived":false,"fork":false,"pushed_at":"2024-12-24T13:40:47.000Z","size":123,"stargazers_count":72,"open_issues_count":1,"forks_count":15,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-04T02:43:48.839Z","etag":null,"topics":["bash","bash-script","maintenance-mode","maintenance-page","maintenance-scripts","nginx","nginx-maintenance","nginx-maintenance-mode","nginx-proxy"],"latest_commit_sha":null,"homepage":"https://nginx-maintenance-mode.tmiland.com","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmiland.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-28T18:51:36.000Z","updated_at":"2025-06-11T14:32:02.000Z","dependencies_parsed_at":"2025-02-24T20:51:05.261Z","dependency_job_id":"46664513-2c6b-4b6c-a35f-85a8a4bc1d1c","html_url":"https://github.com/tmiland/Nginx-Maintenance-Mode","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tmiland/Nginx-Maintenance-Mode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmiland%2FNginx-Maintenance-Mode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmiland%2FNginx-Maintenance-Mode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmiland%2FNginx-Maintenance-Mode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmiland%2FNginx-Maintenance-Mode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmiland","download_url":"https://codeload.github.com/tmiland/Nginx-Maintenance-Mode/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmiland%2FNginx-Maintenance-Mode/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001311,"owners_count":26083059,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","bash-script","maintenance-mode","maintenance-page","maintenance-scripts","nginx","nginx-maintenance","nginx-maintenance-mode","nginx-proxy"],"created_at":"2024-10-30T03:10:50.826Z","updated_at":"2025-10-09T11:47:43.421Z","avatar_url":"https://github.com/tmiland.png","language":"Shell","funding_links":["https://www.buymeacoffee.com/tmiland","https://paypal.me/milanddata"],"categories":[],"sub_categories":[],"readme":"# Nginx Maintenance Mode\n\n```\n           _   __      _\n          / | / /___ _(_)___  _  __\n         /  |/ / __ `/ / __ \\| |/_/\n        / /|  / /_/ / / / / /\u003e  \u003c\n       /_/ |_/\\__, /_/_/ /_/_/|_|\n    \t      /____/\n    __  ___      _       __\n   /  |/  /___ _(_)___  / /____  ____  ____ _____  ________\n  / /|_/ / __ `/ / __ \\/ __/ _ \\/ __ \\/ __ `/ __ \\/ ___/ _ \\\n / /  / / /_/ / / / / / /_/  __/ / / / /_/ / / / / /__/  __/\n/_/  /_/\\__,_/_/_/ /_/\\__/\\___/_/ /_/\\__,_/_/ /_/\\___/\\___/\n\n```\n[![GitHub release](https://img.shields.io/github/release/tmiland/Nginx-Maintenance-Mode.svg?style=for-the-badge)](https://github.com/tmiland/Nginx-Maintenance-Mode/releases)\n[![licence](https://img.shields.io/github/license/tmiland/Nginx-Maintenance-Mode.svg?style=for-the-badge)](https://github.com/tmiland/Nginx-Maintenance-Mode/blob/master/LICENSE)\n![Bash](https://img.shields.io/badge/Language-SH-4EAA25.svg?style=for-the-badge)\n\n## Easily toggle on or off maintenance mode with nginx\n\n\n### Screenshots\n![screenshot](https://raw.githubusercontent.com/tmiland/Nginx-Maintenance-Mode/master/img/maintenance.png)\n\n### Installation\n\n#### Download and execute the script:\n\n```bash\n$ git clone https://github.com/tmiland/Nginx-Maintenance-Mode.git\n$ cd Nginx-Maintenance-Mode\n$ cp -rp ./maintenance-page.conf /etc/nginx/snippets/\n$ git clone https://github.com/tmiland/server-error-pages.git /etc/nginx/html/server-error-pages\n$ cp -rp /etc/nginx/html/server-error-pages/_site/maintenance-page.html /etc/nginx/html/server-error-pages/_site/maintenance-page_off.html\n$ chmod +x maintenance.sh\n```\n\n#### Add to server directive\n\n```\nserver {\n\n## Nginx Maintenance Mode\ninclude snippets/maintenance-page.conf;\n\n}\n```\n\n#### Optionally\n\n```bash\n$ ln -s /path/to/Nginx-Maintenance-Mode/maintenance.sh /usr/bin/maintenance\n```\n\n#### Check for errors\n\n```bash\n$ nginx -t \n```\n\n- Add to each virtual server in /etc/nginx/sites-available you want to enable maintenance mode on.\n- Else, add to nginx.conf.\n\n#### Usage\n\n```bash\n$ ./maintenance.sh [hostname] [on/off]\n```\n\n#### Optionally\n\n```bash\n$ maintenance [hostname] [on/off]\n```\n\n*** Note: [hostname] must match the hostname in your.hostname.com.conf/nginx.conf ***\n\n```\nserver {\n\tserver_name your.hostname.com;\n  }\n```\n\n- When maintenance mode is toggled on, maintenance-page_off.html will be copied to $server_name-maintenance-page_on.html. E.g: your.hostname.com-maintenance-page_on.html\n- This way you can use this with multiple virtual servers, and easily toggle on/off maintenance mode individiually for each site.\n- Toggle off, deletes $server_name-maintenance-page_on.html\n\n### Advanced usage\n\n```bash\n$ ./maintenance.sh my.hostname.com on\n$ ./maintenance.sh my-other.hostname.com on\n$ ./maintenance.sh hostname.com on\n$ ./maintenance.sh my.hostname.com off\n$ ./maintenance.sh my-other.hostname.com off\n$ ./maintenance.sh hostname.com off\n```\n\n#### Logic in maintenance-page.conf\n\n```\n\nif (-f /etc/nginx/html/server-error-pages/_site/$server_name-maintenance-page_on.html)\n{\n  return 503;\n}\nerror_page 503 @maintenance;\nlocation @maintenance\n{\n  rewrite ^(.*)$ /$server_name-maintenance-page_on.html break;\n  root /etc/nginx/html/server-error-pages/_site;\n}\n\n```\n\n- If your.hostname.com-maintenance-page_on.html exists, error 503 is returned.\n- If not, operation is back to normal.\n\n## Added Bonus\n\n#### Add support for custom error pages\n\n*** This will add the error pages included in the repo ***\n\n```bash\n$ cp -rp ./error_pages.conf /etc/nginx/snippets/\n$ cp -rp ./error_pages_content.conf /etc/nginx/snippets/\n```\n\n#### Add to server directive\n\n*** Final configuration should look like this: ***\n\n```\nserver {\n\n## Nginx Maintenance Mode\ninclude snippets/maintenance-page.conf;\n## Custom Error Pages\ninclude snippets/error_pages.conf;\n\n}\n```\n\n## Scheduled maintenance\n\nExample shell script:\n\nName the script, someting like: ```pg_backup_cron.sh```\n\n```bash\n#!/usr/bin/env bash\n\n# Turn on maintenance mode\n/path/to/Nginx-Maintenance-Mode/maintenance.sh hostname.com on\n# Run database backups\n/path/to/pgbackup/pg_backup.sh\n# Turn off maintenance mode\n/path/to/Nginx-Maintenance-Mode/maintenance.sh hostname.com off\nexit 0\n```\n\nAdd job to cron:\n\n```\n$ crontab -e\n```\n```\n@daily bash /path/to/pgbackup/pg_backup_cron.sh \u003e /dev/null 2\u003e\u00261 #Automated PostgreSQL Backup on Linux\n```\n\nUsed in this example: [pgbackup - Automated PostgreSQL Backup on Linux](https://github.com/tmiland/pgbackup)\n\n## Why maintenance mode is important\n\n- Helps your SEO rankings\n\nAs [recommended by Google](https://webmasters.googleblog.com/2011/01/how-to-deal-with-planned-site-downtime.html), Maintenace Mode is using the 503 service unavailable result code, which tells search engine crawlers that the downtime is temporary.\n\n## Credits\n\n- Server-Error-Pages\n  - Source: https://github.com/alexphelps/server-error-pages\n- Nginx Maintenance Mode with Integration Testing\n  - Nginx Configuration Example\n  - Source: https://github.com/czerasz/nginx-configuration-examples\n  - Source: https://czerasz.com/2015/04/21/nginx-maintenance-mode/\n\n## Donations\n\u003ca href=\"https://www.buymeacoffee.com/tmiland\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" style=\"height: 60px !important;width: 217px !important;\" \u003e\u003c/a\u003e\n- [PayPal me](https://paypal.me/milanddata)\n- [BTC] : 33mjmoPxqfXnWNsvy8gvMZrrcG3gEa3YDM\n\n#### Disclaimer \n\n*** ***Use at own risk*** ***\n\n### License\n\n[![MIT License Image](https://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/MIT_logo.svg/220px-MIT_logo.svg.png)](https://github.com/tmiland/Nginx-Maintenance-Mode/blob/master/LICENSE)\n\n[MIT License](https://github.com/tmiland/Nginx-Maintenance-Mode/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmiland%2Fnginx-maintenance-mode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmiland%2Fnginx-maintenance-mode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmiland%2Fnginx-maintenance-mode/lists"}