Welcome! Log In Create A New Profile

Advanced

how can i quickly handle alternate config for site downtime?

Posted by Jonathan Vanasco 
Jonathan Vanasco
how can i quickly handle alternate config for site downtime?
December 26, 2008 10:10PM
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 Vanasco <[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

>
> 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 ?
>
>



--
Corey Donohoe
http://atmos.org
http://engineyard.com
Jonathan Vanasco
Re: how can i quickly handle alternate config for site downtime?
December 28, 2008 07:15PM
On Dec 26, 2008, at 4:59 PM, Corey Donohoe 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.
>
> http://www.ruby-forum.com/topic/141251

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?
Ezra Zygmuntowicz
Re: how can i quickly handle alternate config for site downtime?
December 28, 2008 09:20PM
On Dec 28, 2008, at 9:23 AM, Jonathan Vanasco wrote:

>
> On Dec 26, 2008, at 4:59 PM, Corey Donohoe 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.
>>
>> http://www.ruby-forum.com/topic/141251
>
> 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 Zygmuntowicz
ez@engineyard.com
Jonathan Vanasco
Re: how can i quickly handle alternate config for site downtime?
January 06, 2009 08:55PM
On Dec 28, 2008, at 2:58 PM, Ezra Zygmuntowicz 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 ;)
Jonathan Vanasco
Re: how can i quickly handle alternate config for site downtime?
January 07, 2009 12:25AM
On Dec 28, 2008, at 2:58 PM, Ezra Zygmuntowicz 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.

On Tue, Jan 6, 2009 at 2:57 PM, Jonathan Vanasco <[email protected]> wrote:

>
> On Dec 28, 2008, at 2:58 PM, Ezra Zygmuntowicz 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.
>
>
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
--
Posted via http://www.ruby-forum.com/.
On Wed, Jan 07, 2009 at 06:41:54PM +0100, Igor Clark wrote:

> 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;
> }
>

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.


--
Igor Sysoev
http://sysoev.ru/en/
Sorry, only registered users may post in this forum.

Click here to login