"error_page"& "return" bug?

On Sun, Feb 19, 2012 at 10:20 PM, Nginx U. [email protected]
wrote:

   }
   }

}

Finally I promise :slight_smile:

…so, the method above is better than using location / { } block? I’m
confused now.

#############
server {
error_page 503 /error_docs/custom503.html;
location / {
return 503;
…normal configs…
}
location /error_docs/ {
internal;
alias /server/path/to/error_docs/folder;
}
}
#############


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

On Mon, Feb 20, 2012 at 12:19 AM, Nginx U. [email protected]
wrote:

On 19 February 2012 19:44, Edho A. [email protected] wrote:

Also have you tried this one? Instead of plain “return 503;” in server block:
No, I haven’t and don’t plan to at this time because I have a setup
that works fine as posted earlier with images, css etc all loading as
required.

For completeness, the version without if (single page - all requests
returning 503, least overhead etc - put other static resources on
different domain/server):

server {
# listen etc

error_page 503 @503;
return 503;
location @503 {
root /;
# Immediately serves 503 page, not $uri.
# The fallback should never happen.
try_files /file/system/path/to/503.html =500;
}

}


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

On 19 February 2012 20:34, Edho A. [email protected] wrote:

   root /;
   # Immediately serves 503 page, not $uri.
   # The fallback should never happen.
   try_files /file/system/path/to/503.html =500;

}

}

I don’t think involving another domain/server to serve a single page
is a particularly effective approach.

As mentioned, this serves the page as required along with the needed
resources.

   error_page 503 /error_docs/custom503.html;
   if ( $request_uri !~ \.(jpg|gif|png|css|js)$ ) {
           set $tt  "T";
   }
   if ( $request_uri !~ ^/maintenance/$ ) {
           set $tt  "${tt}T";
   }
   if ( $tt = TT ) {
           rewrite ^ /maintenance/ redirect;
   }
   location /maintenance {
           internal;
           return 503;
   }
   location /error_docs {
           internal;
           alias /server/path/to/error_docs/folder;
   }

I have added it to a file 503.default which I just include (uncomment)
in my normal server block

Server {
include /server/path/to/503.default;

}

Nice and easy and all contained in one domain.
Visitors are redirected to a “example.com/maintenance/” url which
helps in passing info.

Works for me but as said, not the only possibility.

On 19 February 2012 21:36, Edho A. [email protected] wrote:

Pretty sure will return 404 when accessing dynamic resources[1].
Hopefully you don’t have any or care about the impact.
No … because there is none as my maintenance page is a static page.
Only thing it uses is javascript which runs on client’s browser .

Anyway, not sure why this is dragging on.

I am perfectly happy with my setup. I don’t want to use a cdn for this
page nor do I need to run a cgi script or similar on it.
If you happen to use or prefer another setup, that’s fine with me as
well.

Goodbye and thanks for your time.

On Mon, Feb 20, 2012 at 12:56 AM, Nginx U. [email protected]
wrote:

I don’t think involving another domain/server to serve a single page
is a particularly effective approach.

Many larger sites use CDN for static contents. And the original config
you wanted (if works) also do exactly that - returning 503 on all
requests.

As mentioned, this serves the page as required along with the needed resources.

Three ifs, two roundtrips on client. Looks much more inefficient to me
:wink:

I have added it to a file 503.default which I just include (uncomment)
in my normal server block

Or one if line:
if ($uri ~ ^/error_docs/) { return 503; }

No need to comment “error_page …” and “location ^~ /error_docs/” on
normal operation.

Works for me but as said, not the only possibility.

Pretty sure will return 404 when accessing dynamic resources[1].
Hopefully you don’t have any or care about the impact.

[1] Images/resources served with rewrites, dynamic javascript/css, etc.


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org