Custom 503 Error Page

Maxim Dounin mdounin at
Sun Feb 3 03:37:11 MSK 2008


On Sat, Feb 02, 2008 at 03:18:27PM -0800, Douglas A. Seifert wrote:

>I am trying to use a test for the existence of a file to return a error
>page with a 503 Temporarily Unavailable response code.  My configuration
>is below.  The problem is that it does not work.  I can see the custom
>error page, but the HTTP status code is 200, not the desired 503.
>If I change the if directive  to this:
>    if (-f $document_root/system/maintenance.html) {
>      rewrite  ^(.*)$  /system/maintenance.html;  # No last
>      return 503;
>    }
>I start getting a 503 HTTP status code, but the content is not my custom
>error page, but rather the default 503 response compiled into the nginx
>Am I doing something terribly wrong?  I would really like to see my
>custom page with a real 503 HTTP status code.

If you want to use custom response for 503 error, you should write

      error_page 503 /system/maintenance.html;

in your config.

Maxim Dounin

More information about the nginx mailing list