How do you give maintenance for your infrastructure when a new BIG deployment comes in?
You can use
Inside of your
What happens here is that we first check for a file named
Outside of location we need to server
And with an exact match for the file (`location =`) we serve that static page from root of
The note about this code is that when your file is named
#linux #nginx #maintenance #maintenance_mode #location #error_page
You can use
nginX
to display a nice page about your maintenance. First of all create your fancy landing page for your maintenance in html format with the name of maintenance_off.html
.Inside of your
server
block in nginX configuration we do like below:server {
...
location / {
if (-f /webapps/your_app/maintenance_on.html) {
return 503;
}
...
}
# Error pages.
error_page 503 /maintenance_on.html;
location = /maintenance_on.html {
root /webapps/your_app/;
}
...
}
What happens here is that we first check for a file named
maintenance_on.html
, if it's present we return 503 Server error
. This error code is returned when server is not available. This code is inside of location
section of root.Outside of location we need to server
/maintenance_on.html
for error 503:error_page 503 /maintenance_on.html;
And with an exact match for the file (`location =`) we serve that static page from root of
/webapps/your_app/
.The note about this code is that when your file is named
maintenance_off.html
maintenance will be ignored and when we rename the file to maintenance_on.html
then error 503 is returned.#linux #nginx #maintenance #maintenance_mode #location #error_page