Is this how variable (set $var) inheritance works?

Edho Arief edho at myconan.net
Fri Feb 3 15:26:07 UTC 2012


(doesn't seem to be specified in documentation)

My test showed:
- anything set in server { } block is inherited:

server {
  set $something /usr/share/something;
  ...
  location / {
    location /nested/ {
      # $something is set to /usr/share/something
      root $something;
    }
  }
}

- anything set in location { } block is not inherited:

server {
  ...
  location /~ {
    location ~ ^/~([^/]+)(|/.*)$ {
      set $userfile /home/$1/public_html/$2;
      alias $userfile;
      location ~ \.php$ {
        include fastcgi_params;
        # $userfile is empty here
        fastcgi_param SCRIPT_FILENAME $userfile;
        fastcgi_pass 127.0.0.1:9000;
    }
  }
}



Is it correct?


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



More information about the nginx mailing list