V
V
VITYA-XY12019-11-01 12:28:12
Nginx
VITYA-XY1, 2019-11-01 12:28:12

How to set the value of keepalive_timeout as a variable?

I need to close a connection to a group of clients by a condition (this could be an IP address, UA, referrer, etc.),
so I need to declare it as a map, like this:

map $remote_addr $test_keepalive {
            default                  "30";
           "4.4.4.4"                  "0";
    }

As a solution, to close the connection, I tried to set a parameter in the location block (maybe this is important): But after running nginx -t I get an error:
keepalive_timeout $test_keepalive;
nginx: [emerg] "keepalive_timeout" directive invalid value

Is it possible to solve this issue, or solve it in another way (it is necessary to disable the connection by condition for a group of clients , I know how to do this through a redirect to an error)?
Thanks

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question