Welcome! Log In Create A New Profile

Advanced

[Solved] Re: Returning a 503 status code using try files with a maintenance page activated

Zev Blut
May 14, 2012 10:02AM
Hello,

On 05/10/2012 11:52 AM, Zev Blut wrote:
> Is it possible to remove the "if return 503" logic and have the
> try_files logic from the nginx documentation, but have nginx return a
> 503 when the maintenance page is found?
>
> I have a number of location directives that all have this "if return
> 503" logic and would like to reduce this duplication.

I have found a work around to my question.

I push the "if return 503" check into the location that defines
the proxy pass.

My working example becomes:

<example>
location / {
try_files $uri $uri/index.html $uri.html @mongrel;
}

location @mongrel {
if (-f /system/maintenance.html) {
return 503;
break;
}
proxy_pass http://mongrel;
}

error_page 503 /system/maintenance.html;

location = /system/maintenance.html {
root /app;
}

</example>


In the end, I do not use the maintenance path in the try_files.
This may not look like much of a change, but my refactoring helps
reduce the checks when I have multiple location directives that
all end with pass to @mongrel.


Zev

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Returning a 503 status code using try files with a maintenance page activated

Zev Blut May 09, 2012 10:54PM

[Solved] Re: Returning a 503 status code using try files with a maintenance page activated

Zev Blut May 14, 2012 10:02AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 165
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready