Hello,<br><br>I'm using httpluamodule+redis to make a dynamic proxy to use in a mass vhost environment. I need to limit requests/s for specifics http_host. I tried to do something like that:<br><br>-------------------------------------------------------------------------------------<br>
limit_req_zone $http_host zone=one:10m rate=1r/s;<br><br>upstream redisbackend {<br> server <a href="http://127.0.0.1:6379">127.0.0.1:6379</a>;<br>}<br><br>server {<br><br> listen xxxxx:80 default_server;<br>
<br> location = /redis {<br> internal;<br> redis2_query get $arg_key;<br> redis2_pass redisbackend;<br> }<br><br> location / {<br> default_type 'text/html';<br>
set $backendserver '';<br> set $limit '';<br><br> access_by_lua '<br> local key = ngx.var.http_host<br> local res = ngx.location.capture(<br>
"/redis", { args = { key = key } }<br> )<br><br> m = ngx.re.match(res.body, "([a-z]+):([0-9\.]+):([0-9]+)")<br> if m ~= nil then<br> user = m[1]<br>
ngx.var.backendserver = m[2]<br> ngx.var.limited = tonumber(m[3])<br> end<br> ';<br><br> if ($limited = 1) {<br> limit_req zone=one burst=2;<br>
}<br><br> proxy_set_header X-Forwarded-For $remote_addr;<br> proxy_set_header Host $http_host;<br> proxy_redirect off;<br><br> proxy_pass http://$backendserver:888;<br>
break;<br><br> }<br>}<br><br>------------------------------------------------------------------------------------------------------------------------------<br><br>When I reload nginx I'm getting the following error:<br>
<br>nginx: [emerg] "limit_req" directive is not allowed here in /etc/nginx/conf.d/default.conf:64<br><br><br>Is there a way to limit specific websites using just 1 virtual host (server directive)?<br><br>Regards,<br>
<br>Guilherme<br><br>