# default
set $maintenance false;
# maintenance enable flag file
if (-e /var/tmp/do_maintenance) {
set $maintenance true;
}
# except maintenace dir
if ($uri ~ "^/maintenance/") {
set $maintenance false;
}
# except health check file
if ($uri = "/health_check.html") {
set $maintenance false;
}
# except remote ip
if ($remote_addr = 124.35.147.218) {
set $maintenance false;
}
# except forwarded ip
if ($http_x_forwarded_for = "124.35.147.218") {
set $maintenance false;
}
error_page 503 /maintenance/maintenance.html;
location /maintenance/ {
root /data/var/www/html;
}
if ($maintenance = true) {
return 503;
}