Welcome! Log In Create A New Profile

Advanced

Re: limit_req applied to upstream auth_request requests?

Maxim Dounin
July 17, 2018 03:34PM
Hello!

On Tue, Jul 17, 2018 at 01:08:13PM -0400, jarstewa wrote:

> Hi, I currently have an nginx configuration that uses the limit_req
> directive to throttle upstream content requests. Now I'm trying to add
> similar rate limiting for auth requests, but I haven't been able to get the
> auth throttle to kick in during testing (whereas the content throttle works
> as expected). Is there some known limitation of using limit_req against
> auth_request requests, or do I simply have a problem in my configuration?

The limit_req directive doesn't try to limit requests already
limited, as well as subrequests within these requests. You should
configure all limits you want to apply to a request in one place.

> location /out/ {
> auth_request /auth;

[...]

> #Throttling works here <---
> limit_req zone=content burst=50 nodelay;
> limit_req_status 429;
> }
>
> location /auth {
> internal;

[...]

> limit_req zone=auth burst=50 nodelay;
> limit_req_status 429;
> }

Note well that this configuration implies that every request to
"/out/..." will generate a subrequest to "/auth". As such, you
can safely move the "limit_req zone=auth ..." limit to "location
/out/", as results will be (mostly) identical.

Note well that auth subrequest is expected to return either 2xx,
or 401, or 403. Anything else, including 429 you are trying to
configure in the provided snippet, will be considered an error, and
nginx will return 500 to the client.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

limit_req applied to upstream auth_request requests?

jarstewa July 17, 2018 01:08PM

Re: limit_req applied to upstream auth_request requests?

Maxim Dounin July 17, 2018 03:34PM

Re: limit_req applied to upstream auth_request requests?

jarstewa July 17, 2018 05:23PM

Re: limit_req applied to upstream auth_request requests?

Maxim Dounin July 18, 2018 08:18AM

Re: limit_req applied to upstream auth_request requests?

jarstewa July 18, 2018 02:13PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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