Welcome! Log In Create A New Profile

Advanced

Re: Nginx map value not matched when used as input of another map

Maxim Dounin
July 18, 2016 02:12PM
Hello!

On Mon, Jul 18, 2016 at 01:59:06PM -0400, Linna.Ding wrote:

> I just tested with a single map "cache_key", and the rate limiting doesn't
> work, the $cache_key was logged as empty string. But changing
> $upstream_cache_status to non-upstream variables like $remote_addr and
> adding an IP match value will make the rate limiting work.
> The zone I defined like so:
> limit_req_zone $cache_key zone=cache_host:1m rate=1r/m;
> map $upstream_cache_status $cache_key {
> HIT $host;
> EXPIRED $host;
> - $host;
> default "";
> }
> And I use it in one of my server chunk with limit_req directive below:
> limit_req zone=cache_host busrt=1;
>
> Since I am using Nginx as reverse proxy, is this because
> $upstream_cache_status value is set after the request is sent to origin
> server and got the response, while $cache_key is used in rate limit zone
> which checked before the request was sent to origin server?
> If so, is there a recommended way to implement rate limiting only for
> request that MISS cache?

This doesn't looks like a development-related question. Please
use the nginx@ mailing list instead, see
http://nginx.org/en/support.html.

--
Maxim Dounin
http://nginx.org/

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

Nginx map value not matched when used as input of another map

Linna.Ding 497 July 18, 2016 02:00PM

Re: Nginx map value not matched when used as input of another map

Maxim Dounin 223 July 18, 2016 02:12PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 254
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