Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 2 down vote accepted

"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 {
}
share|improve this answer
    
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: gist.github.com/1965393 –  iGEL Mar 3 '12 at 10:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.