How can i quickly handle alternate config for site downtime?

for the pat few years, i have stuff like this:

file: /hosts/findmeon
content:
include /hosts/findmeon/www.findmeon.com ;
#include /hosts/findmeon/www.findmeon.com-downtime ;

when i want to take a domain up/down, i just toggle to comment line
for the include, and restart nginx like magic.

i’m wondering if there is a better way?

ideally i’d like to be able to either have some sort of if/else logic
in nginx , and maybe either a command-line or file based way (this
way kill -HUP still works )

or maybe someone else has a better method ?

On Fri, Dec 26, 2008 at 1:49 PM, Jonathan V. [email protected]
wrote:

for the pat few years, i have stuff like this:

file: /hosts/findmeon
content:
include /hosts/findmeon/www.findmeon.com ;
#include /hosts/findmeon/www.findmeon.com-downtime ;

Is this other config file pointing tosome kind of status page that
says “findmeon.com is down right now!” or something similar? If it
is, you prolly wanna investigate maintenance pages and have them
return 503s during the downtime.

http://www.ruby-forum.com/topic/141251

On Dec 26, 2008, at 4:59 PM, Corey D. wrote:

Is this other config file pointing tosome kind of status page that
says “findmeon.com is down right now!” or something similar? If it
is, you prolly wanna investigate maintenance pages and have them
return 503s during the downtime.

Custom 503 Error Page - NGINX - Ruby-Forum

hmm… that could work.

would you be able to share those 2 snippets you listed as a pastie
again ? they expired ( as did your old link at http://
forum.engineyard.com/forums/3/topics/22 )

also - just to be sure about this… you’re triggering a downtime
response just by a file-existence check, right?

On Dec 28, 2008, at 9:23 AM, Jonathan V. wrote:

hmm… that could work.

would you be able to share those 2 snippets you listed as a pastie
again ? they expired ( as did your old link at http://forum.engineyard.com/forums/3/topics/22
)

also - just to be sure about this… you’re triggering a downtime
response just by a file-existence check, right?

Jonathan-

Yeah we are triggering a maintenance page via the existance of a
file. Here is how it looks in the config file.

Rewrite all the requests to the maintenance.html page if it exists.

if (-f $document_root/system/maintenance.html) {
return 503;
}

error_page 503 @503;
location @503 {
rewrite ^(.*)$ /system/maintenance.html break;
}

This means that if $document_root/system/maintenance.html exists,
then only serve that file and nothing else for every request.

Cheers-
Ezra Z.
[email protected]

On Dec 28, 2008, at 2:58 PM, Ezra Z. wrote:

Jonathan-

Yeah we are triggering a maintenance page via the existance of a
file. Here is how it looks in the config file.

that’s a really elegant solution , using semaphores.

reminds me of some not-so-dirty hacks in modperl :wink:

On Dec 28, 2008, at 2:58 PM, Ezra Z. wrote:

error_page 503 @503;
location @503 {
rewrite ^(.*)$ /system/maintenance.html break;
}

forgive my constant questions on this…

can you explain the @ ?

its not in the docs anywhere.

a friend thinks it might be a namespace that you know you aren’t using.

just trying to figure this out, as I can’t seem to trigger the custom
error and i think that might be part of it.

Yes, it sets up a location that you are most likely never going to use.
It
appears to be convention within nginx configurations. I don’t know when
it
started, but I’ve seen it on this list for some time now. I am pretty
sure
that you could use other special characters if you wanted, too, it’s
just a
character to nginx.

Merlin wrote:

Yes, it sets up a location that you are most likely never going to use.
It appears to be convention within nginx configurations. I don’t know
when it started, but I’ve seen it on this list for some time now. I am
pretty sure that you could use other special characters if you wanted,
too, it’s just a character to nginx.

Igor S refers to these as “named locations”. A common use is e.g.

location / {
    error_page 404 = @myapp;
}

location @myapp {
    fastcgi_index blah;
    fastcgi_param ...;
}

so that any URLs that would normally go through rewrite stages like

if (! -e $uri) {
    rewrite ....;
}

are automatically routed to the appropriate back-end.

In release 0.7.27 Igor S added the try_files directive which works
similarly but adds a list of filesystem locations to try before hitting
a named location as default, and only logs errors in case of total
failure (as I understand it):

    location / {
            try_files $uri $uri/index.html @myapp;
    }

I haven’t seen any characters other than @ used to notate named
locations, but I’m sure Igor S will be able to elucidate.

Cheers,
Igor

On Wed, Jan 07, 2009 at 06:41:54PM +0100, Igor C. wrote:

location / {
if (! -e $uri) {
    location / {
            try_files $uri $uri/index.html @myapp;
    }

The errors will not be logged at all. On total failure nginx will do
internal redirect to last parameter (@myapp in this case).

I haven’t seen any characters other than @ used to notate named
locations, but I’m sure Igor S will be able to elucidate.

The “@” is speacial symbol to indicate “named location”.
The “named locations” are used in error_page redirection to preserve
URI.