Custom 503 Error Page

Maxim Dounin mdounin at mdounin.ru
Sun Feb 3 05:34:01 MSK 2008


Hello!

On Sat, Feb 02, 2008 at 06:16:15PM -0800, Douglas A. Seifert wrote:

>
>On Sun, 2008-02-03 at 04:20 +0300, Maxim Dounin wrote:
>> Hello!
>> 
>> On Sat, Feb 02, 2008 at 05:08:29PM -0800, Douglas A. Seifert wrote:
>> 
>> >
>> >> >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
>> >> >server.
>> >> >
>> >> >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.
>> >> 
>> >
>> >Thanks for the response.  Unfortunately, however, that has no effect.  I still see the compiled in 503 content.
>> 
>> Probably because you have error_page 503 redefined later in your 
>> config to /503.html.
>> 
>Maxim,
>Thanks for trying, but it doesn't matter where in the config the
>error_page directive is placed, the result is the same: a 503 response
>with the compiled in 503 content.

Just another quick note: due to some implementation wierdness of 
ngx_http_rewrite_module, it may be required to define error_page 
_before_ if/return block. Try something like this:

     error_page 503 /system/maintenance.html;

     if (-f ...) {
         return 503;
     }

Maxim Dounin





More information about the nginx mailing list