Code for dynamic generation of the HTML file (via symlink)
This suggestion is more performant than having nginx read the contents of a file on each request.
if [ -s maintenance_file.txt ]; then ln -s `cat maintenance_file.txt`
maintenance.html; elif [ -f maintenance.html ]; then rm maintenance.html; fi
NGiNX Directives
server {
...
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
if (-f $document_root/system/down_for_a_while.html) {
rewrite ^(.*)$ /system/down_for_a_while.html last;
break;
}
...
}
Created on 9/2/2018