Display configuration at runtime?

Francis Daly francis at daoine.org
Mon Apr 16 23:05:57 UTC 2012

On Mon, Apr 16, 2012 at 06:02:45PM -0400, michael_teter wrote:

Hi there,

> My error log shows nothing, but my
> access log does show the visit.

The error log doesn't seem immediately useful in this case; but with
the debug log you can work out what is happening.

The short answer is "internal redirect", or "subrequest".

> Here's the relevant part of my config:

>       error_page 503 /maintenance.html;
>       if (-f $document_root/../tmp/stop.txt) {
>         set $maintenance 1;
>       }
>       if ($maintenance) {
>         return 503;
>       }

For any request, if the file exists then return 503, which does an
internal redirect to /maintenance.html. This subrequest goes through the
same process, and since the file still exists, you would end up in a loop.

With the following config, you can break out of the loop:

        error_page 503 /maintenance.html;
        if ($uri = "/maintenance.html") {
        if (-f $document_root/../tmp/stop.txt) {
            return 503;

Although I confess I don't know if there is a "best" way to implement
a 503 response to all requests in nginx based on the existence of a
flag file.

Francis Daly        francis at daoine.org

More information about the nginx mailing list