Welcome! Log In Create A New Profile

Advanced

Re: [nginx] Using User-Agent & IP address to rate limit

July 28, 2014 12:43PM
Thanks for the prompt feedback! Yes, the continuous if directives put my teeth on edge as well. Using a map block to introduce variables for $zone and $burst respectively, I tried this already and had continuous errors. Attempting this again (per your suggestions), I have this error --

nginx: [emerg] invalid burst rate "burst=$burst" in /usr/local/nginx/conf/nginx.conf:69

With line 69 as follows --

limit_req zone=$zone burst=$burst;

Reading the limit_req directives (http://nginx.org/en/docs/http/ngx_http_limit_req_module.html) instructions there is no information specifying that you can use a variable to set these values. Likewise I do not believe you can use limit_req inside the context of an if directive (as you can with proxy_pass for example - http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass). My attempt to read off the value of $http_user_agent and set the limit_req inside an if block resulted in many "nginx: [emerg]" errors.

My second thought now is to use nested locations after doing a rewrite on the $uri and inside these nested locations set the limit_req, log the info, and proxy_pass along. This way the request doesn't have to start over.
Subject Author Posted

[nginx] Using User-Agent & IP address to rate limit

lorenanicole July 28, 2014 11:35AM

Re: [nginx] Using User-Agent & IP address to rate limit

B.R. July 28, 2014 12:18PM

Re: [nginx] Using User-Agent & IP address to rate limit

lorenanicole July 28, 2014 12:43PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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