I'm trying to set up a maintenance page for an application, hosted via NGINX web server.
Currently I have this set up.
location ^~/maintenance/ {
root /path/to/the/maintenance/maintenance.html;
}
set $maintenance 0;
if (-f /path/to/the/maintenance/maintenance.enable) {
set $maintenance 1;
}
if ($maintenance = 1) {
root /path/to/the/maintenance/maintenance.html
rewrite ^/(.*) /maintenance/maintenance.html break;
}
I have explicit CSS file in maintenance/CSS and images in maintenance/CSS
The behaviour with this set up is the case file is also getting rendered as the HTML doc and images are also not accessible when maintenance.enable file is present.
This worked out when I moved the location block to the bottom of the logic(if Statements).
Since there was no issue in the syntax or anything, but nginx was trying to see the location once the conditions were met, but it did not find a location to work on. Correct me if I'm wrong as I'm new to nginx, I would love to get some insights of this scenario.