I have a following nginx config:
http {
(...)
limit_conn_zone $binary_remote_addr zone=limitapinoauth:16m;
limit_conn_zone $remote_user zone=limitapi:32m;
map $remote_user $zone {
default 'limitapi';
'' 'limitapinoauth';
}
map $zone $num {
'limitapi' 100;
default 200;
}
server {
listen 80 default;
root /var/www/example.com/public_html;
limit_conn $zone $num;
}
(...)
}
Expected behavior is that mapped variables are evaluated to use in last line, but they aren't. Any idea why?
I get the following error:
nginx: [emerg] invalid number of connections "$num"
When I change $num to integer, i.e. 200, the error is:
nginx: [emerg] zero size shared memory zone "$zone"
If I change last line to:
limit_conn limitapi 100;
the config is correct.