Forum: NGINX root not recognized

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3c53e91d2a6ceb1b7f202d709f638b1b?d=identicon&s=25 Sean Allen (Guest)
on 2009-01-01 00:07
(Received via mailing list)
ok, well better put on root is recognized, a second isnt.

have this setup ( lots of snipping here... )

root /some/path;
....

location /
{
   if ( -f /tmp/.maintenance )
   {
     set $site_maintenance 1;
   }

   if ( $site_maintenance )
   {
     root /maintenance/path;
     rewrite (.*) /maintenance/index.html;
   }
}

problem is... the rewrite works just fine but its trying to serve

/some/path/maintenance/index.html
instead of
/maintenance/path/maintenance/index.html

any idea why?
7b660a44f60a7ba9bb6e12d817f4b038?d=identicon&s=25 Mathew Davies (Guest)
on 2009-01-01 03:13
(Received via mailing list)
Try using the $document_root variable

rewrite (.*) $document_root/maintenance/index.html;

On Wed, Dec 31, 2008 at 10:56 PM, Sean Allen
3c53e91d2a6ceb1b7f202d709f638b1b?d=identicon&s=25 Sean Allen (Guest)
on 2009-01-01 16:01
(Received via mailing list)
That doesn't work.

I get a 404 for that.
3c53e91d2a6ceb1b7f202d709f638b1b?d=identicon&s=25 Sean Allen (Guest)
on 2009-01-01 16:04
(Received via mailing list)
I figured out why the below didnt work for me.

I left out one key point about root /some/path;

We are actually doing:

set $root $base/public;
root $root;

because conf files are shared by multiple sites. this way each site
set $base
and it gets reused in different places... to make the below work, with
that
i need to change

>  if ( $site_maintenance )
>  {
>    root /maintenance/path;
>    rewrite (.*) /maintenance/index.html;
>  }

to

if ( $site_maintenance )
{
   set $root /maintenance/path;
   rewrite (.*) /maintenance/index.html
}

which is TOTALLY not how I expected variables to work.
is this documented somewhere?

that if you set root with a variable, to later change root you have
to change the value of the variable and that using root will have no
effect?
This topic is locked and can not be replied to.