3

I try to set up a maintenance page for my rails app, using this snipplet.

error_page 503 /system/maintenance.html;
if (-f $document_root/system/maintenance.html) {
  return 503;
}

This works as far as the presence of the maintenance.html causes the webserver to return a 503. But it returns the minimal nginx default error_page, not my maintenance.html. Why?

nginx 1.0.12 on Ubuntu 10.04 LTS

The complete vhost configuration: https://gist.github.com/1948225

iGEL
  • 265
  • 1
  • 2
  • 7

1 Answers1

4

"if" and "return" directives are the part of ngx_rewrite_module. Since you declare such condition at server level you don't live a chance to nginx to handle error_page.

Make your config clear:

root /home/igel/www/stage.example.com/current/public;
error_page 503 /system/maintenance.html;

location / {
       if ( -e /system/maintenance.html ) {
              return 503;
       }
}
location = /system/maintenance.html {
}
Vadim
  • 1,339
  • 9
  • 8
  • Thanks, I modified your code a little, though, since the rails app didn't work, if I didn't specify passenger_enabled within the location: https://gist.github.com/1965393 – iGEL Mar 03 '12 at 10:20