To show maintenance page during deploy I've always used next config in nginx:
if (-f /home/shared/system/maintenance.html) {
return 503;
}
error_page 503 @maintenance;
location @maintenance {
root /home/shared/errors;
rewrite ^(.*)$ /maintenance.html break;
}
And everything was ok until I needed to add static content to maintenance page (images, stylesheets, etc.)
No of static content work with such logs in error.log:
2011/05/05 02:47:20 [notice] 13760#0: *6 "^(.*)$" matches "/some.jpg", client: x.x.x.x, server: server.com, request: "GET /some.jpg HTTP/1.1", host: "server.com"
2011/05/05 02:47:20 [notice] 13760#0: *6 rewritten data: "/maintenance.html", args: "", client: x.x.x.x, server: server.com, request: "GET /some.jpg 2 HTTP/1.1", host: "server.com"
Which is logical - if I do rewrite everything to maintenance.html that means that static content is not exclusion.
But I cannot find any proper solution to make redirect to every file except that ones which are physically existed in root /home/shared/errors
folder.
PS. /home/shared/errors
does not share any resources with common project folder - this is completely separate folder (even without any symlinks to /current
for the project.