Maintenance message pages

Alexander Staubo alex at purefiction.net
Mon Aug 6 21:10:16 MSD 2007


On 8/6/07, Roxis <roxis at list.ru> wrote:
> On Monday 06 August 2007, Alexander Staubo wrote:
> > is there any way I can check for the presence of an HTTP
> > header in an "if" expression?
>
> $http_header_name ?

That's pretty much undocumented, but it works, thanks. Now since Nginx
does not do boolean logic expressions, I am left with two blocks that
cannot be combined:

    if ($http_X_Requested_With ~ XMLHttpRequest) {
      rewrite /.*/ /maintenance_ajax.html last;
      return 200;
    }

and

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

Ideally, the first line should say:

    if (-f $document_root/.maintenance && $http_X_Requested_With ~
XMLHttpRequest) {

Alexander.





More information about the nginx mailing list