From 86c45908286c51a824f3364b18057c53c30e097a Mon Sep 17 00:00:00 2001 From: Dmytro Bogatov <dmytro@dbogatov.org> Date: Thu, 22 Feb 2018 23:53:40 -0500 Subject: [PATCH] Add proper status codes. --- .gitignore | 1 + configs/page-not-found.conf | 21 +++++++++++++++++++++ configs/under-maintenance.conf | 15 +++++++++++++++ deploy.sh | 1 + nginx.conf | 6 ------ 5 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 configs/page-not-found.conf create mode 100644 configs/under-maintenance.conf delete mode 100644 nginx.conf diff --git a/.gitignore b/.gitignore index dcaf716..1971016 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ index.html +nginx.conf diff --git a/configs/page-not-found.conf b/configs/page-not-found.conf new file mode 100644 index 0000000..9506a4b --- /dev/null +++ b/configs/page-not-found.conf @@ -0,0 +1,21 @@ +server { + server_name _; + + error_page 404 /index.html; + + # Everything is a 404 + location / { + return 404; #return the code 404 + } + + location = /healthz { + return 200; + } + + # link the code to the file + location = /index.html { + root /srv/; + } + + +} diff --git a/configs/under-maintenance.conf b/configs/under-maintenance.conf new file mode 100644 index 0000000..194e338 --- /dev/null +++ b/configs/under-maintenance.conf @@ -0,0 +1,15 @@ +server { + server_name _; + + error_page 503 /index.html; + + # Everything is a 404 + location / { + return 503; #return the code 404 + } + + # link the code to the file + location = /index.html { + root /srv/; + } +} diff --git a/deploy.sh b/deploy.sh index d691138..ef6b963 100755 --- a/deploy.sh +++ b/deploy.sh @@ -11,6 +11,7 @@ do rm -f ./index.html cp $site ./index.html + cp ./configs/$IMAGE.conf ./nginx.conf docker build -t registry.dbogatov.org/dbogatov/nginx-placeholders/$IMAGE . diff --git a/nginx.conf b/nginx.conf deleted file mode 100644 index 4e00f59..0000000 --- a/nginx.conf +++ /dev/null @@ -1,6 +0,0 @@ -server { - server_name _; - - root /srv; - index index.html; -} -- GitLab