Welcome! Log In Create A New Profile

Advanced

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

Maxim Dounin
February 03, 2012 01:12PM
Hello!

On Fri, Feb 03, 2012 at 10:26:07PM +0700, Edho Arief wrote:

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

Yes, this is expected behavrious. Rewrite module directives are
never inherited, and directives specified inside location are only
executed if this exact location matches.

See here for details:
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

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

Edho Arief February 03, 2012 10:28AM

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

Maxim Dounin February 03, 2012 01:12PM

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

Edho Arief February 03, 2012 01:50PM

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

Edho Arief February 03, 2012 01:52PM

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

Edho Arief February 03, 2012 02:00PM

Re[2]: Is this how variable (set $var) inheritance works?

Max February 03, 2012 08:16PM

Re: Re[2]: Is this how variable (set $var) inheritance works?

Edho Arief February 03, 2012 09:54PM

Re: Re[2]: Is this how variable (set $var) inheritance works?

António P. P. Almeida February 03, 2012 10:24PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 213
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready