S
S
sechin2019-04-07 07:41:24
Nginx
sechin, 2019-04-07 07:41:24

How to exclude requests with query_string from limit_req in nginx?

use for main location

location / {
limit_req zone=bot burst=10 nodelay;
}

If you need not to limit the number of requests to any of the directories, you can write it below a separate location, for example
location /images {
}

But how not to limit queries with, say, a non-empty query_string? After all, in this example, they will still fall into one of the locations, and if it is a /?get=1 request, then it will be limited by the bot rule.
From what I found, query_string cannot be correlated with location, only a crutch.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-04-07
@sechin

nginx.org/ru/docs/http/ngx_http_limit_req_module.h...
Let's say it was like this: You need to use map to create a new variable, for example, which will return an empty string as a key for limit_req_zone if there is something in $args.

map $args   $key_ {
    ""      $key;
    default "";
}
limit_req_zone $key_ zone=bot:10m rate=1r/s;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question