503 custom error page
Stefan Caunter
stef at caunter.ca
Fri Dec 23 15:15:34 UTC 2011
On Fri, Dec 23, 2011 at 7:35 AM, Maxim Dounin <mdounin at mdounin.ru> wrote:
> On Fri, Dec 23, 2011 at 05:11:57AM -0500, djeyewater wrote:
>
>> I'm trying to get a maintenance page working for my site. I added the
>> following to the server block:
>>
>> error_page 503 /maintenance.html;
>> return 503;
>>
>> This serves 503 but with default nginx 503 error page.
>>
>> The following works okay, but I don't understand why the above doesn't
>> show the custom 503 page?
>
> The error_page in question does internal redirect to
> "/maintanance.html", which in turn returns 503 due to "return 503"
> at sever level.
>
> I.e. there is no way to reach /maintanance.html, and hence nginx
> returns builtin page.
>
> Using "return 503" at location level will work, assuming you'll
> define special location for /maintenance.html without the return.
> i.e.:
>
> location / {
> error_page 503 /maintenance.html;
> return 503;
> }
>
> location /maintanance.html {
> # no "return 503" here
> }
I've done this with 403 and allow/deny so that the world sees
maintenance page, but developers can keep working. Create a second
directory with your maintenance view.
error_page 403 /403.html;
location = /403.html {
root /home/site_maintenance;
allow all;
}
location = /maintenance.png {
root /home/site_maintenance;
allow all;
}
Then for the control of the actual site directory:
location / {
# let internal subnet keep developing
allow a.b.c.d;
# everyone else triggers 403
deny all;
root /home/site;
index index.php;
try_files $uri $uri/ @handler;
}
>
>
>> error_page 503 @503;
>> return 503;
>> location @503 {
>> try_files /maintenance.html =503;
>> }
>
Stefan Caunter
http://scaleengine.com/contact
More information about the nginx
mailing list