rate limiting – Nginx URL ratelimit regardless client IP

You might have already seen this page: docs.nginx.com/nginx/admin-guide/security-controls/controlling-access-proxied-http/

I believe that has the answer, in the section that talks about using $server_name instead of $binary_ip_address.

I believe in any of the examples on that page, using $server_name instead of ip address will essentially make it a global setup, because the server name should be the same every time. So even though most examples on that page are setup to be “separate per client IP address”, if you replace $binary_ip_address with $server_name in any example then I think it would be what you want.

We can’t use an empty-string as that value, I’d say, per this comment in the docs (nginx.org/en/docs/http/ngx_http_limit_conn_module.html#limit_conn_zone):

Requests with an empty key value are not accounted.

Read more here: Source link