set directive not working when mirror is used

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

set directive not working when mirror is used

PALMA Mickael
Hi,

Here is my location directive :

server {
  # Start with an undefined API name, each API will update this value
  set $api_name -;

  [...]

  location = /_oauth {
    internal;
    set $api_name 'Oauth API';

    # Policy configuration here (authentication, rate limiting, logging, more...)
    mirror /_mirrored_api;
  }
}

In my log I only get “-“ as api_name but if I comment the mirror directive I get 'Oauth API’.

Any idea how to avoid that.
I always want the name to be ''Oauth API’'.

Regards,
 
Mickaël Palma
Responsable domaine & valorisation

11-13 rue des Petits Hôtels
75010 Paris
Tel :  01.53.29.35.53  |  Fax : 01.53.29.11.66


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: set directive not working when mirror is used

Maxim Dounin
Hello!

On Fri, Sep 20, 2019 at 07:59:15AM +0000, PALMA Mickael wrote:

> Hi,
>
> Here is my location directive :
>
> server {
>   # Start with an undefined API name, each API will update this value
>   set $api_name -;
>
>   [...]
>
>   location = /_oauth {
>     internal;
>     set $api_name 'Oauth API';
>
>     # Policy configuration here (authentication, rate limiting, logging, more...)
>     mirror /_mirrored_api;
>     proxy_pass http://$upstream$request_uri;
>   }
> }
>
> In my log I only get “-“ as api_name but if I comment the mirror directive I get 'Oauth API’.
>
> Any idea how to avoid that.
> I always want the name to be ''Oauth API’'.

The problem is that variables space is shared among all
subrequests, including mirror one.  As such, "set $api_name -;" in
the mirror subrequest overrides the one previously set for the
request.  The only solution is to avoid changing variables you
don't want to be changed.  In this particular configuration -
consider removing "set ..." from the server level.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: set directive not working when mirror is used

PALMA Mickael
Thank you Dimitry,

I will remove the default value.
It will be empty by default in stead of ‘-‘ not a big loss ;-)

Regards.

On 20 Sep 2019, at 14:54, Maxim Dounin <[hidden email]> wrote:

Hello!

On Fri, Sep 20, 2019 at 07:59:15AM +0000, PALMA Mickael wrote:

Hi,

Here is my location directive :

server {
 # Start with an undefined API name, each API will update this value
 set $api_name -;

 [...]

 location = /_oauth {
   internal;
   set $api_name 'Oauth API';

   # Policy configuration here (authentication, rate limiting, logging, more...)
   mirror /_mirrored_api;
   proxy_pass http://$upstream$request_uri;
 }
}

In my log I only get “-“ as api_name but if I comment the mirror directive I get 'Oauth API’.

Any idea how to avoid that.
I always want the name to be ''Oauth API’'.

The problem is that variables space is shared among all 
subrequests, including mirror one.  As such, "set $api_name -;" in 
the mirror subrequest overrides the one previously set for the 
request.  The only solution is to avoid changing variables you 
don't want to be changed.  In this particular configuration - 
consider removing "set ..." from the server level.

-- 
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx