【发布时间】:2022-12-27 20:33:25
【问题描述】:
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.
【问题讨论】:
-
Hi Emir. Excuse me for that, but it is unclear for me. What you're trying to achieve is that if
maintenance.enableexists, redirect each request tomaintenance.html, is it ? -
Hi Philippe, Yes I'm trying to have an explicit maintenance mode setup without having to edit the config for the maintenance mode. If the maintenance.enable file is present I'm redirecting the requests.
标签: nginx nginx-config maintenance-plan