Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

share|improve this question
up vote 4 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/;
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: – iGEL Mar 3 '12 at 10:20

Your Answer


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.